英文:
How can I convert ISCII encoding to unicode for Gujarati language in Python 3?
问题
我有一些古吉拉特语字符串,但它是以ISCII编码方式编码的,所以Python报错(SyntaxError: invalid decimal literal)。
string = TFH[TZDF\ I]GF.8[0 G[Xg;
第1行
string = TFH[TZDF\ I]GF.8[0 G[Xg;
^
SyntaxError: 行继续符后出现意外字符
我尝试了字节编码,但它没有像ISCII编码那样输出。
我正在尝试将ISCII转换为古吉拉特语的Unicode。
我有基于ISCII的字体和字符映射数据。
ISCII输入字符串:TFH[TZDF\ I]GF.8[0 G[Xg;
期望的Unicode输出:તાજેતરમાં યુનાઇટેડ નેશન્સ(使用古吉拉特语音键盘输入)
<details>
<summary>英文:</summary>
I have some Gujarati string but its in ISCII encoding, so python throughing error (SyntaxError: invalid decimal literal).
```python
string = TFH[TZDF\ I]GF.8[0 G[Xg;
line 1
string = TFH[TZDF\ I]GF.8[0 G[Xg;
^
SyntaxError: unexpected character after line continuation character
I was tried byte encoding too, but its not giving output like ISCII encoding.
I am trying this to make ISCII into unicode for Gujarati language.
I have ISCII based font and character map data also.
ISCII input string: TFH[TZDF\ I]GF.8[0 G[Xg;
Desired unicode output: તાજેતરમાં યુનાઇટેડ નેશન્સ (Typed using gujarati phonetic keyboard)
答案1
得分: 1
如果您只想写字符串文字,对我来说,只需写print("તાજેતરમાં યુનાઇટેડ નેશન્સ")
即可。
或者您可以写:
characters = [2724, 2750, 2716, 2759, 2724, 2736, 2734, 2750, 2690, 32, 2735, 2753, 2728, 2750, 2695, 2719, 2759, 2721, 32, 2728, 2759, 2742, 2728, 2765, 2744]
string = str()
for c in characters:
string += chr(c)
也许您可以查看这个转换脚本:
https://gist.github.com/pathumego/81672787807c23f19518c622d9e7ebb8
英文:
If you just want to write the string literal, for me, just writing print("તાજેતરમાં યુનાઇટેડ નેશન્સ")
worked.
Or you could write:
characters = [2724, 2750, 2716, 2759, 2724, 2736, 2734, 2750, 2690, 32, 2735, 2753, 2728, 2750, 2695, 2719, 2759, 2721, 32, 2728, 2759, 2742, 2728, 2765, 2744]
string = str()
for c in characters:
string += chr(c)
Maybe you have a look at this conversion script:
https://gist.github.com/pathumego/81672787807c23f19518c622d9e7ebb8
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论