打印希伯来语 UTF-8 会产生乱码 [英] Printing Hebrew UTF-8 produces giberish

查看:93
本文介绍了打印希伯来语 UTF-8 会产生乱码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试打印一个搅拌器,但由于某种原因它变成了乱码.但是如果我把它放在一个在线 utf 8 转换器中,它就可以工作(https://www.browserling.com/tools/utf8-decode).我得到的输出是:תיכו×××××"שליט"而不是:תיכוןדהשליט",我在网站上看到的,是原始的搅拌.

I try to print a stirng and for some reason it's turn into gibrish. But if I put it in an online utf 8 convertr it works (https://www.browserling.com/tools/utf8-decode). And the output i get is: "תיכון ×"×" שליט" instead of: "תיכוןדהשליט" that I get in the website and is the orignal stirg.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
print '\xd7\xaa\xd7\x99\xd7\x9b\xd7\x95\xd7\x9f \xd7\x93\xd7\x94 \xd7\xa9\xd7\x9c\xd7\x99\xd7\x98'

推荐答案

您只需要使用 utf8 编码将字节解码回 unicode ......默认情况下,它使用您的终端正在使用的任何东西(可能是 latin1)......您的终端可能不支持所有字符 *(参见 https://repl.it/回复/OnlyRewardingKeyboard 宏)

you just need to decode the bytes back into unicode with utf8 encoding ... by default its using whatever your terminal is using(probably latin1) ... your terminal may not support all of the characters * (see https://repl.it/repls/OnlyRewardingKeyboardmacro)

print '\xd7\xaa\xd7\x99\xd7\x9b\xd7\x95\xd7\x9f \xd7\x93\xd7\x94 \xd7\xa9\xd7\x9c\xd7\x99\xd7\x98'.decode('utf8')

这篇关于打印希伯来语 UTF-8 会产生乱码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆