简体   繁体   English

从utf-8代码打印/输出utf-8字符

[英]Print/output utf-8 character from utf-8 code

I have string containing utf8 code in my HTML file such as /tr'ʌmpɪt/ , I want the utf8 code to be printed as utf8 character in the document. 我的HTML文件中有包含utf8代码的字符串,例如/tr'ʌmpɪt/ ,我希望将utf8代码打印为文档中的utf8字符 ˈtrəmpit

Which library provide this functions? 哪个库提供此功能? Ruby , JavaScript all works for me, Python is also okey. RubyJavaScript都对我有用, Python也不错。

Provided the document is already encoded in utf-8. 如果文档已经使用utf-8编码。

For Python, use eg (following this post ): 对于Python,请使用eg(在本文之后 ):

import HTMLParser
h=HTMLParser.HTMLParser()
print h.unescape('trʌmpɪt')
# trʌmpɪt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM