I have very strange problem (I have searched - this is a common problem, but I don't find any working solution).
I'm using C# (.net 4.0) and SQLite. Pragma encoding shows me UTF8, so I want to save data in this encoding. I tried to use somelike this:
private String ToUTF8(string input) {
Encoding ecdng = Encoding.Default;
byte[] bts = ecdng.GetBytes(input);
ecdng = Encoding.UTF8;
return ecdng.GetString(bts, 0, bts.Length);
//return input;
}
private String FromUTF8(string input)
{
Encoding ecdng = Encoding.UTF8;
byte[] bts = ecdng.GetBytes(input);
ecdng = Encoding.Default;
return ecdng.GetString(bts, 0, bts.Length);
//return input;
}
but it doesn't work. I use ToUTF8 when I'm going to save data and FromUTF8 when I selecting data.
Second solution which I found is:
private IDbDataParameter AddParameter(IDbCommand command, string paramName, DbType type, object value)
{
IDbDataParameter parameter = command.CreateParameter();
parameter.ParameterName = paramName;
parameter.DbType = type;
if (value != null)
parameter.Value = value;
else
parameter.Value = DBNull.Value;
command.Parameters.Add(parameter);
return parameter;
}
but it doesn't work too.
I want to store in my database polish words. When I preview data via SQLiteStudio I have strange symbols in place of polish letters. In program I have the same problem, but other symbols on polish letters.
Can anyone help me with this?
Best Regards, Matt.
Stringuses. You do not need to do anything in your code.