2011-05-24 16 views
1

Emacs上で"D\xC3\xA9cada"、Décadaのような文字列を読み取ることができません。どうやら、それは次のエラーを返し、\xA9cadaに対応する文字、有効な16進を見つけようとし、それを見つけることができない:問題のある修飾語で文字列を読むにはどうすればよいですか?

ELISP> "D\xC3\xA9cada" 
*** Read error *** Invalid modifier in string 

は、最初の2つで修飾子を見つけるために読者を制限するための任意の方法があります。 xを超える文字、または一般的な回避策? '\ xA9'を '\ 251'に置き換えると、この場合は動作しますが、文字列 '\ xA9000'にはない可能性があります。

ありがとうございます!


EDIT:最後に、私はこれを考慮に入れるために、文字列生成プログラムを変更しなければなりませんでした。すべてのシーケンスに '\'が追加されます。 Rubyでは:puts string.gsub(/(\\x[0-9A-F][0-9A-F])([0-9A-Fa-f])/,'\1\\\\ \2')

答えて

2

Emacs Lisp manualを参照してください:

You can also represent a multibyte non-ASCII character with its character code: use a hex escape, ‘\xnnnnnnn’, with as many digits as necessary. (Multibyte non-ASCII character codes are all greater than 256.) Any character which is not a valid hex digit terminates this construct. If the next character in the string could be interpreted as a hex digit, write ‘\ ’ (backslash and space) to terminate the hex escape—for example, ‘\x8e0\ ’ represents one character, ‘a’ with grave accent. ‘\ ’ in a string constant is just like backslash-newline; it does not contribute any character to the string, but it does terminate the preceding hex escape.
+0

だから、それは機能ではなく、バグです:D – konr

関連する問題