6 に答える
Because you must encode the data in a string, I am assuming it is because you are interfacing with other systems. Why not use something like XML or JSON for this rather than inventing your own data format?
With XML you can specify the encoding in use, e.g.:
<?xml version="1.0" encoding="UTF-8"?>
Unicodeテキストを保存および取得するシステムがこれらの特定の文字を変更する危険性はほとんどありません。
テキスト転送プロセスで変更できる主な文字は、行末マーカーです。たとえば、UnixシステムからWindowsシステムにテキストモードでファイルをFTPで転送すると、CARRIAGE RETURN +LINEFEEDのペアのLINEFEED文字が置き換えられる場合があります。
その後、一部のシステムはテキストの正規化を実行する場合があります。正規化(合成または分解)が考慮されていない限り、文字と発音区別符号が付いた文字を組み合わせて使用しないでください。Unicode文字データベースには、これらの正規化スキームで必要な変換に関する情報が含まれています。
それは注意すべき最大のことを要約しており、それらのどれもあなたがリストしたキャラクターにとって問題ではありません。
行われる可能性はあるが可能性は低い他の変換は、ケースの変更と互換性の正規化です。これらを回避するには、アルファベット文字やアルファベット文字のように見えるものには近づかないでください。一部のシンボルも互換性の正規化で変換されるため、Unicode文字データベースのプロパティを確認する必要があります。ただし、システムが互換性の正規化を実行することを明示的に示さずに実行する可能性はほとんどありません。
Unicodeコードチャートでは、正規化は「≡」で示され、互換性の正規化は「≈」で示されます。
You could take the same approach as URL or HTML encoding, and replace key chars with sequences of chars. I.e. &
becomes &
.
Although this results in more chars, it could be pretty efficiently compressed due to the repetition of those sequences.
Well, UNICODE is a standard, so as long as everybody involved (code, db, etc) is using UNICODE, you shouldn't have any problems.
There are rarer characters in the Unicode set. As far as I know, only the chars below 0x32 (space) have special meanings, anything abovde that should be preserved in an NVARCHAR data column.
It is never going to be totally safe unless you have a good specification what characters can and cannot be part of your data.
Remember some of the laws of Murphy:
"Anything that can go wrong will."
"Anything that can't go wrong, will anyway."
Those characters that definitely will not be used, may eventually be used. When they are, the application will definitely fail.
You can use any character you like as delimiter, if you only escape the values so that character is guaranteed not to appear in them. I wrote an example a while back, showing that you could even use a common character like "a" as delimiter.
Escaping the values of course means that some characters will be represented as two characters, but usually that will still be less of an overhead than using a multiple character delimiter. And more importantly, it's completely safe.