Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate multiple unicode string?

I have two unicode string '가' and 'ㄱ' and I want to concatenate them to get "가ㄱ"

This is my code:

output1 = unicodeQueue(self.queue) # first unicode result
output2 = unicodeQueue(self.bufferQueue) # second unicode result
sequence = [output1, output2]
print sequence
output = ''.join(sequence)
return output

And this is the output I'm getting:

[u'\uac00', u'\u3131']
ㄱ가가ㄱ가

I don't know why it doesn't produce correct result, can anyone help me with this?

like image 270
user1732445 Avatar asked Nov 05 '12 13:11

user1732445


1 Answers

if you want to concatenate two strings use +

>>> '가' + 'ㄱ'
'\xea\xb0\x80\xe3\x84\xb1'
>>> u'가' + u'ㄱ'
u'\uac00\u3131'
>>> print u'가' + u'ㄱ'
가ㄱ

this means you can use

output1 + output2
like image 96
User Avatar answered Oct 20 '22 23:10

User