1
from jsonrpclib import jsonrpc

url = 'https://myserver.com:443'
jpc = jsonrpc.Server('%s/jsonrpc' % url)
new_string = "金衣大俠"
jpc.editqueue("NewName", new_string, 123)

The new_string appears as Ñc'à in my server. The server supports foreign characters, if I copy the text in new_string I can paste and save it in the server through the UI (not using jsonrpc) and it appears just fine. I would guess I have to encode my string a certain way for this to work. Any ideas on how I can encode my string for it to work ?

YatShan
  • 425
  • 2
  • 8
  • 22
asdwad23
  • 11
  • 1
  • Does this answer your question? [Chinese and Japanese character support in python](https://stackoverflow.com/questions/14682933/chinese-and-japanese-character-support-in-python) – AMC Feb 19 '20 at 23:38

2 Answers2

0

Please clarify:

encode my string *in a certain way

You can use inbuilt string encode / decode function.

new_string = u'金衣大俠' #force it to unicode

# On the client side:
encoded_string = new_string.encode('utf-16')

# and on the server side:
decoded_string = received_string.decode('utf-16')
  • I have no control over server decoding. I tried encoding utf-16, appeared as ` x00` on the server. I was looking for some guesses on what decoding the server is using (so I know how to encode) based on the mapping of "金衣大俠" to "Ñc'à" – asdwad23 Feb 19 '20 at 23:49
0

Python encoding has been answered in a different stack exchange already. Kindly reference the link here and define new_string on line 5 appropriately

Abhaas Goyal
  • 36
  • 1
  • 3
  • I have no control over server decoding. I tried encoding utf-16 appeared as ` x00` on the server. I was looking for some guesses on what decoding the server is using (so I know how to encode) based on the mapping of "金衣大俠" to "Ñc'à" utf-8 and utf-16 both failed. – asdwad23 Feb 19 '20 at 23:57