Hi all I'm using the python generated code to create a generic gpb object editor, and I've run into unicode issues. Here's a small example for the protofile example.proto
# example.proto message test { required string s=1; } #!/usr/bin/python # -*- coding: utf-8 -*- from PyQt4.QtGui import * from example_pb2 import * from google.protobuf import text_format ustring = u"ﺵﺎﻫﺩﺓ ﺐﺛ" astring = "hello" T = test() T.s=astring # str(ustring) # T.s=ustring # FAILS #print text_format.MessageToString(T) # the stuff below here is to see that i have no other encoding issues. The QLabel correctly # shows the same characters as the original string app = QApplication([]) l = QLabel() l.setText(ustring) l.show() app.exec_() Using the unicode string (T.s = ustring) fails with TypeError: u'\u0634\u0627\u0647\u062f\u0629 \u0628\u062b' has type <type 'unicode'>, but expected one of: (<type 'str'>,) How do I get my unicode data into my message? I can't coerce my unicode into <type 'str'> I think. Bart P.S. the gpb object editor I'm building is open source and can be got from http://github.com/bvdeenen/gpbedit/tree/master P.P.S I have no idea what the unicode means, it's from an Al Arabya headline. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~----------~----~----~----~------~----~------~--~---