如何在Python 3中将ISCII编码转换为古吉拉特语的Unicode?

huangapple go评论57阅读模式
英文:

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(&quot;તાજેતરમાં યુનાઇટેડ નેશન્સ&quot;)即可。
或者您可以写:

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(&quot;તાજેતરમાં યુનાઇટેડ નેશન્સ&quot;) 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

huangapple
  • 本文由 发表于 2023年6月2日 03:15:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76385033.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定