← Back to team overview

mosquitto-users team mailing list archive

Re: unicode strings

 

Hi,

I'm using 2.7 and it's a unicode string: u'привет' - I'm actually getting
them from my gtalk_daemon

type(message) will return unicode

I'm now using a dirty walkaround:

def send_message(self, topic, message):
            if type(message) == unicode:
                message = str(message).encode('string_escape')
            result, some_number = Client.mc.publish(topic, message)

this is not really good because now all strings, even plain latin will be
the same type...


Sasha Bolotnov
www.bolotnov.info



On Mon, Feb 11, 2013 at 11:15 PM, Roger Light <roger@xxxxxxxxxx> wrote:

> Hi,
>
> I'm not near a computer right now, but can you tell me what version of
> python you are using and how you are creating the string?
>
> Thanks,
>
> Roger
> On Feb 11, 2013 6:48 PM, "Alexander Bolotnov" <abolotnov@xxxxxxxxx> wrote:
>
>> While trying to send unicode strings to mosquitto with python client I
>> get the following:
>>
>> TypeError: payload must be a string, bytearray, int, float or None.
>>
>> how do I then submit unicode data?
>>
>> Sasha Bolotnov
>> www.bolotnov.info
>>
>>
>> --
>> Mailing list: https://launchpad.net/~mosquitto-users
>> Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~mosquitto-users
>> More help   : https://help.launchpad.net/ListHelp
>>
>>

Follow ups

References