1

How to extort using utf8 for strings in SqlServer CE?

To save 'ą', 'ę' etc. language special characters?

@Edit:

I use EntityFramework and when db is mysqlserver data have special characters like 'ą', 'ę' but when I swtich to SqlServerCompact the data lost special chars.

1 Answer 1

1

SQL Server CE supports nvarchar and ntext, which are UTF-16. Basically: store your data as UTF-16 in an nvarchar column, and you'll be set. Conveniently, .NET is also mostly UTF-16 (the char and string types are implemented as UTF-16), so this works out just fine.

If you absolutely must use UTF-8, you'll have to use varbinary / image, which means you lose most of the useful features of a database. You'll be able to store and retrieve, but filtering and other operations are much harder.

When storing data, make sure you either use N'foo' syntax for literals, or ADO.NET parameters of DbType.String (nvarchar) / DbType.StringFixedLength (nchar), and not DbType.AnsiString (varchar) / DbType.AnsiStringFixedLength (char)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.