News for hackers. Stuff that matters.
Re:Mercurial’s journey to and reflections on Python 3 by Dylan16807 on Tuesday January 14, 2020 @03:22AM (#22042861)
> If you are representing strings as bytes, you are intrinsically using an encoding.

It's just binary data that might resemble a string. No encoding necessary.

Re:Mercurial’s journey to and reflections on Python 3 by fiedzia on Tuesday January 14, 2020 @06:07AM (#22043692)
This is false more often than not. Many programs taking user input will treat it as string, assuming specific encoding or compatibility with screen output/some api, at least in some code paths. For example if you print an error message when you can't open some file, you are very likely to assume its encoded in a way terminal can handle, so its no longer "just binary data".
Re:Mercurial’s journey to and reflections on Python 3 by CJefferson on Tuesday January 14, 2020 @05:40PM (#22049988)
Yes, I have to worry about how to make a "best effort" to show it to users, but in all internal code paths it must stay as "just binary data", else I lose information. This is exactly how chrome and Firefox handle headers internally.
Re:Mercurial’s journey to and reflections on Python 3 by cbsmith on Wednesday January 15, 2020 @12:57PM (#22056518)
It might resemble a particular encoding of a string... and the way you got that string to that particular sequence of bytes is by... encoding it.
Re:Mercurial’s journey to and reflections on Python 3 by Dylan16807 on Wednesday January 15, 2020 @06:11PM (#22059855)
> and the way you got that string to that particular sequence of bytes

No I didn't. Those bytes came from an external source. My primary job is to preserve the exact sequence, whether I can make sense of it or not.

Re:Mercurial’s journey to and reflections on Python 3 by cbsmith on Thursday January 16, 2020 @03:52AM (#22062748)
In that context, you aren't using strings. You are using bytes. HTML without interpreting it as strings isn't really HTML, nor is it a string. It's just a blob that is passing through.