Unicode strings into a SQLite database

前端 未结 2 1257
时光说笑
时光说笑 2021-01-06 19:06

I would like some help with my Visual Studio C# code with inserting unicode strings into a SQLite database.

Below is my test code to write a test string to the datab

相关标签:
2条回答
  • 2021-01-06 19:26

    You can try with this code

    byte[] encod = Encoding.Default.GetBytes(testStr );
    string result = Encoding.UTF8.GetString(encod);
    myParameters.AddWithValue("@name", result);
    
    0 讨论(0)
  • 2021-01-06 19:30

    This problem turned out to be an issue with the SQLite Administrator app I was using to view/check the db/data. Seems it was this app that would not display the characters correctly when inserted by my code. Strangely though if you used the SQLite Administrator app to add the test text directly (by copy & pasting the test string into the table/field) it would display, save & subsequently view OK. Anyway now using SourceForge SQLite Database Browser to check my code writes correctly and all seems in order.

    Many thanks for anyone who took the time to comment, hope this is of help to someone else.

    0 讨论(0)
提交回复
热议问题