When talking about this issue, it is entirely because sqilte does not support Chinese paths. To be accurate, it is not supported. Second, it only supports Chinese paths in UTF8 encoding format. I believe many of my friends have encountered this problem.
Google and Baidu yisearch are all such solutions:
[Csharp]
String ikoktest = "test ";
Byte [] utf8bytes = System. Text. Encoding. Default. GetBytes (ikoktest );
Ikoktest = System. Text. Encoding. UTF8.GetString (utf8bytes );
Do you think the encoding has been converted?
The answer is: indeed, the conversion.
But why can't I open the database ?!
Debug and see what ikoktest has become :"???? "
No one knows the real garbled characters.
Let's take a look at this Code:
[Csharp]
String ikoktest = "zookeeper failed ";
Byte [] utf8bytes = System. Text. Encoding. Default. GetBytes (ikoktest );
Ikoktest = System. Text. Encoding. UTF8.GetString (utf8bytes );
Check the value of ikoktest In the debugging result: "test"
Do you understand?
The real purpose of the above example is as follows: when a character is encoded in UTF8 format, it is stored as Default (usually GBK or GB2312) and displayed, in this case, we can use the above example to correct the problem. Www.2cto.com
In practical application, what should we do if we want to "test" the Default encoding to UTF8?
It should be like this:
[Csharp]
String ikoktest = "test ";
Byte [] utf8bytes = System. Text. Encoding. Default. GetBytes (ikoktest );
Byte [] utf8bytes2 = System. Text. Encoding. Convert (System. Text. Encoding. Default, System. Text. Encoding. UTF8, utf8bytes );
Ikoktest = System. Text. Encoding. Default. GetString (utf8bytes2 );
Convert Converts an array of characters from one encoding format to another encoding format.
Note that this is Default, not UTF8.
Ikoktest = System. Text. Encoding. Default. GetString (utf8bytes2 );
This means that the UTF-8 encoded string will be saved in the default format. Although you see garbled characters: "encoding", it is UTF-8 encoded, it can be decoded correctly only when it is passed to a library or dll that supports UTF8.