Better HN
topnewbestaskshowjobs
Log inSign up

mikezter1

2 karma · joined Oct 6, 2018 (8y ago) · 2 submissions

Submissions

comment 8y ago · link · parent

The encoding is a property of the string, just like the content, just as with any other object. If you want to compare strings with different encodings, you'll have to convert at least one of them.

I was never forced into encoding hell again, after reading this excellent post: https://www.joelonsoftware.com/2003/10/08/the-absolute-minim...

comment 8y ago · link · parent

> The encoding of a string should never cause a comparison to fail when the two strings are equivalent except for the encoding.

You'll have to admit that the encoding is a property of a string, just like the content itself. As always, you as a programmer are bound to know both of these properties to have predictable results. To compare two strings of different encoding to one another, you'll have to find a common ground for interpreting the data contained in the string.

If you don't want or need that, then all you have is a "string" of bytes.