2

これはpythonでの変換です。ロケールは「utf-8」です

>>> s1="你好"   #你好 = how are you?
>>> s2=unicode(s1,"utf-8")
>>> s2
u'\u4f60\u597d'                #s2  is the unicode form of s1
>>> s3=s2.encode("utf-8")
>>> s3
'\xe4\xbd\xa0\xe5\xa5\xbd'     #s3  is the utf-8 form of s1
>>> s4=s2.encode("gbk")
>>> s4 
'\xc4\xe3\xba\xc3'              #s3  is the gbk  form of s1

Rでどうやってそれを行うことができますか?

4

1 に答える 1

3

utf-8からへの変換に役立つ 2 つの関数がありますhexmode

  • utf8ToInt
  • as.hexmode

これを試して:

as.hexmode(utf8ToInt(s1))
[1] "4f60" "597d"

しかし、gbk変換に関しては、申し訳ありませんが、手がかりがありません。

于 2012-09-01T13:19:03.227 に答える