We accept the accented characters such as Ḿấxiḿứś from a html form, when using hibernate saves it into the database the string becomes ??xi???
Then I did a SQL update, trying to write the accented words directly into the database, the same result happened.
The desired behavior is to set into the dabase as what it is.
I am using Microsoft SQL Server 2008.
I have tried to google it, someone said I need to change the database collation to SQL_Latin1_General_CP1_CI_AI. But I can't find this options from the dropdown.
Only one of these works: nvarchar datatype and N prefix for unicode constants.
DECLARE
@foo1 varchar(10) = 'Ḿấxiḿứś',
@foo2 varchar(10) = N'Ḿấxiḿứś',
@fooN1 nvarchar(10) = 'Ḿấxiḿứś',
@fooN2 nvarchar(10) = N'Ḿấxiḿứś';
SELECT @foo1, @foo2, @fooN1, @fooN2;
You have to ensure that all datatypes are nvarchar end to end (columns, parameters, etc)
Collation is not the issue: this is for sorting and comparison for nvarchar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With