1 module qrcode.utils;
2 
3 // converter datatype
4 alias void* iconv_t;
5 
6 // allocate a converter between charsets fromcode and tocode
7 extern (C) iconv_t iconv_open(char* tocode, char* fromcode);
8 
9 // convert inbuf to outbuf and set inbytesleft to unused input and
10 // outbuf to unused output and return number of non-reversable
11 // conversions or -1 on error.
12 extern (C) size_t iconv(iconv_t cd, void** inbuf, size_t* inbytesleft,
13         void** outbuf, size_t* outbytesleft);
14 
15 // close converter
16 extern (C) int iconv_close(iconv_t cd);
17 
18 ///编码转换
19 string iconv_charset(string inbuf, string tocode, string fromcode)
20 {
21     return "";
22 }
23 /// '1' to 1
24 int charToInt(char c)
25 {
26     c -= '0';
27     return c <= 9 ? c : -1;
28 }