You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test="Hi there :)"printlen(test), test//Prints"11 Hi there :)"test=test.replace(" ", "\x00")
printlen(test), test//Prints "11
On Windows '\x00' is same as ' ', but on linux string is terminated at first occurance of '\x00'. Results on problems with pySerial and binary data, so I can't replace '\x00' with ' '.
Python 2.7.3+ (2.7:1f5d2642929a, May 25 2012, 12:47:34)
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> test ="Hi there :)"
>>> printlen(test), test
11 Hi there :)
>>> test = test.replace("", "\x00")
>>> printlen(test), test
11 Hithere:)
Your comment on the last line of your example seems to have been truncated, so I'm not sure what you really saw.
Jānis, please present examples as proper python -- indentation and comment char -- so others can copy/paste to run without editing.
In Idle (tkinter -- tk), '\0' is displayed as a wider space than ' '. The console is fixed pitch, so it cannot do that.
I suspect that the response of a window to \0 is window system dependent and probably out of our control. If so, this issue should be closed.
This is not what I get on Linux: I see "11 Hithere:)" because the console chooses to not print the \x00. The character is present in the output stream though.
Did you really got a truncated output? How did you run the above script?
Activity
jjanis commentedon Jun 6, 2012
On Windows '\x00' is same as ' ', but on linux string is terminated at first occurance of '\x00'. Results on problems with pySerial and binary data, so I can't replace '\x00' with ' '.
bitdancer commentedon Jun 6, 2012
Windows makes \x00 a space? How odd.
This is the result for me on linux:
Your comment on the last line of your example seems to have been truncated, so I'm not sure what you really saw.
terryjreedy commentedon Jun 8, 2012
Jānis, please present examples as proper python -- indentation and comment char -- so others can copy/paste to run without editing.
In Idle (tkinter -- tk), '\0' is displayed as a wider space than ' '. The console is fixed pitch, so it cannot do that.
I suspect that the response of a window to \0 is window system dependent and probably out of our control. If so, this issue should be closed.
[-]Sting termination on Linux[/-][+]String termination on Linux[/+]amauryfa commentedon Jun 15, 2012
Jānis:
This is not what I get on Linux: I see "11 Hithere:)" because the console chooses to not print the \x00. The character is present in the output stream though.
Did you really got a truncated output? How did you run the above script?
birkenfeld commentedon Mar 28, 2013
Closing due to lack of response.