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

后端 未结 5 708
长发绾君心
长发绾君心 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 06:00

    What SQL Implementation(s) are you talking about?

    I can speak about Microsoft Sql Server; other SQL implementations, not so much.

    For Microsoft SQL Server, the default collation is SQL_Latin1_General_CP1_CI_AS (Latin 1 General, case-preserving, case-insensitive, accent-sensitive). It allows the round-trip representation of most western European languages in single-byte form (varchar) rather than double-byte form (nvarchar).

    It's built on the "Windows 1252" code page. That code page is effectively ISO-8859-1 with the code point range 0x80–0x9F being represented by an alternate set of glyphs, including the Euro symbol at 0x80. ISO-8859-1 specifies that code point range as control characters, which have no graphical representation.

    ISO-8859-1 consists of the first 256 characters of Unicodes Basic Multilinigual Plane, covering the entire domain of an 8-bit character (0x00–0xFF). For details and comparison see

    • Unicode CO Controls and Basic Latin
    • Unicode C1 Controls and Latin-1 Supplement
    • Window 1252 Code Page
    • ISO-8859-1

    Western European languages that will have a hard time with this collating sequence include (but aren't necessarily limited to) Latvian, Lithuanian, Polich, Czech and Slovak. If you need to support those, you'll either need to use a different collation (SQL Server offers a plethora of collations), or move to using nvarchar.

    One should note that mixing collations within a database tends to cause problems. Deviating from the default collation should be done only when necessary and with an understanding of how you can shoot yourself in the foot with it.

    I suspect Oracle and DB2 provide similar support. I don't know about MySQL or other implementations.

提交回复
热议问题