New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
String termination on Linux #59224
Comments
test = "Hi there :)"
print len(test), test // Prints "11 Hi there :)"
test = test.replace(" ", "\x00")
print len(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 ' '. |
Windows makes \x00 a space? How odd. This is the result for me on linux: 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 :)"
>>> print len(test), test
11 Hi there :)
>>> test = test.replace(" ", "\x00")
>>> print len(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. 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. |
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? |
Closing due to lack of response. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: