Print an arabic unicode string in Python(x,y) -


this question has answer here:

i have arabic unicode string want print in python (using python(x,y) on windows 7), can't print, unicode representation printed out.

the string defined as:

ss = u'\u0647\u0630\u0627 \u0647\u0648 \u0627\u0644\u062d\u0644 \u0627\u0644\u0648\u062d\u064a\u062f \u0644\u0644\u0645\u0634\u0643\u0644\u0629 \u0627\u0644\u062a\u064a \u0646\u0648\u0627\u062c\u0647\u0647\u0627' 

and should this: "هذا هو الحل الوحيد للمشكلة التي نواجهها"

when try print, gives following error

print ss traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "c:\python27\lib\encodings\cp1252.py", line 12, in encode     return codecs.charmap_encode(input,errors,encoding_table) unicodeencodeerror: 'charmap' codec can't encode characters in position 0-2: character maps <undefined> 

when encode string, cp1256 (windows arabic), gives wrong representation:

print ss.encode('cp1256') åÐÇ åæ ÇáÍá ÇáæÍíÏ ááãÔßáÉ ÇáÊí äæÇÌååÇ 

i have looked @ several questions here related printing unicode python on windows, nothing seems work.

any ideas?

thanks.

update: using spyder ide (bundled python(x,y) on windows 7).

update2: tried solutions in "duplicate" questions, none worked.

your console configured display codepage 1252 (latin 1), indeed cannot handle codepoints. switch console different codepage can display characters.

you switch 1256:

chcp 1256 

or switch 65001 (the utf-8 codepage), should able handle any unicode codepoint. may have switch font used console though; lucida sans reported display of unicode.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -