Can the French and Spanish special chars be held in a varchar?

后端 未结 5 724
长发绾君心
长发绾君心 2021-02-14 05:01

French and Spanish have special chars in them that are not used in normal English (accented vowels and such).

Are those chars supported in a varchar? Or do I need a nva

5条回答
  •  逝去的感伤
    2021-02-14 05:41

    The characters that can be stored in a varchar field depend entirely on what code page is defined for that particular field. If there are specific characters that you want to store, then you can choose a code page that will store those characters, and it should work. Badly.

    My advice is to always use nvarchar to store strings in a SQL database. In fact, I would consider non-Unicode character encodings to be a bug, whether it is in a database or anywhere else.

    Your operating system uses Unicode internally (whether Windows, Mac, Linux, or whatever). The JVM and the .NET Framework use Unicode internally. There is simply no point to doing code page conversions every time you query a database. There is no point to doing code page conversions every time you write to a database. Just use an nvarchar column, and your strings will go straight from your application to the database untouched—no character conversion lookups, no fallback encoding error handlers, no wierd characters or unexpected question marks.

    By using nvarchar for all of your string data in your databases—and Unicode in general everywhere—you can stop concerning yourself with encodings and focus on the core functionality of your application, now and forever.

    Today is the day to abandon legacy character encodings.

    Do it for the maintainers who are coming after you. Do it for your children. Do it for yourself.

提交回复
热议问题