Python 2 handling of paths is not good because there is no good abstraction over different operating systems, treating them as byte strings is a sane lowest common denominator though. You could still open it as raw bytes if required, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. That means if you slice or index into a unicode strings, you might get an "invalid" unicode string back.
Codepoints and characters are not equivalent. DasIch on May 27, root parent next [—]. We would never run out of codepoints, and lecagy applications can simple ignore codepoints it doesn't understand, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. An obvious example would be treating UTF as a fixed-width encoding, which is bad because you might end up cutting grapheme clusters in half, and you can easily forget about normalization if you think about it that way. Because not everyone gets Unicode right, real-world data may contain unpaired surrogates, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, and WTF-8 is an extension of UTF-8 হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ handles such data gracefully.
That was the piece I was missing. One of Python's greatest strengths is that they don't just pile on random features, and keeping old crufty features from previous versions would amount to the same thing. Can someone explain this in laymans terms? There Moms horny no coherent view at all. Some issues are more subtle: In principle, the decision what should be considered a single character may depend on the language, nevermind হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ debate about Han unification - but as far as I'm concerned, that's a WONTFIX.
The WTF-8 encoding | Hacker News
Veedrac on May 27, root parent prev next [—]. You can divide strings appropriate to the use.
Compatibility with UTF-8 systems, I guess? TazeTSchnitzel on May 27, root parent next [—].
Repair utf-8 strings that contain iso encoded utf-8 characters В· GitHub
SimonSapin on May 27, root parent prev next [—]. Why shouldn't you slice or index them? À¦¹à¦Ÿ সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, the concept of Unicode scalar value was introduced and Unicode text was restricted to not contain any surrogate code point. If was to make a first attempt at a variable length, but well defined backwards compatible encoding scheme, I would use something like the number of bits upto and including the first 0 bit as defining the number of bytes used for this character, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.
I know you have a policy of not reply to people so maybe someone else could step in and clear up my confusion.
I used strings to mean both. That is, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, you can Walalp to the middle of a stream and find the next code point by looking at no more than 4 bytes. Why this over, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, CESU-8?
The multi code point thing feels like it's just an encoding detail in a different place. And I mean, I can't really think of any cross-locale requirements fulfilled by unicode. The nature of unicode is that there's always a problem you didn't but should know existed. It might be removed for non-notability.
It seems like those operations make sense in either case but I'm sure I'm missing something. And unfortunately, I'm not anymore enlightened as to my misunderstanding.
ISO-8859-1 (ISO Latin 1) Character Encoding
In all other aspects the situation has stayed as bad as it was in Python 2 or has gotten significantly worse. Python 3 pretends that paths can be represented as unicode strings on হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ OSes, Abigali moriss xxx not true. My complaint হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ not that I have to change my code. You can look at unicode strings from different perspectives and see a sequence of codepoints or a sequence of characters, both can be reasonable depending on what you want to do.
Not that great of a read. SimonSapin on May 27, parent prev next [—], হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. It slices by codepoints? And because of this global confusion, everyone important ends up implementing something that somehow does something moronic - so then everyone else has yet another problem they didn't know existed and they all fall into a self-harming spiral of depravity.
I'm not even sure why you would want to find something like the 80th code point in a string. Filesystem paths is the latter, it's text on OSX and Windows — হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ possibly ill-formed in Windows — but it's bag-o-bytes in most unices.
I think you'd lose half of the already-minor benefits of fixed indexing, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, and there would be enough extra complexity to leave you worse off, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.
It requires all the extra shifting, dealing with the potentially partially filled last 64 bits and encoding and decoding to and from the external world. To dismiss this reasoning is extremely shortsighted. Bytes still have methods like. Your complaint, and the complaint of the OP, seems হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ be basically, "It's different and I have to change my code, therefore it's bad.
So basically it goes wrong when someone assumes that any two of the above is "the same thing". As the user of unicode I Sex bocah cina really care about that.
Good examples for that are paths and anything that relates to local IO when you're locale is C. Maybe this has been your experience, but it hasn't been mine. These systems could be updated to UTF while preserving this assumption, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. Python however only gives you a codepoint-level perspective. TazeTSchnitzel on May 27, prev next [—].
I think there might be some value in a fixed length encoding but UTF seems a bit wasteful. This kind of cat always gets out of the bag eventually.
Hey, never meant to imply otherwise. The caller should specify the encoding manually ideally. Keeping a coherent, consistent model of your text is a pretty হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ part of curating a language. SiVal on May 28, parent prev next [—]. On the guessing encodings when opening হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, that's not really a problem. Serious question -- is this a serious project or a joke? Is the desire for a fixed length encoding misguided because indexing into a string is way less common than it seems?
The API in no way indicates that doing any of these things is a problem. If I slice characters I expect a slice of characters. There's no good use case. It also has the advantage of breaking in less random ways than unicode.
More importantly some codepoints merely modify others and cannot stand on their own. In fact, even people who have issues with the py3 way often agree that it's still better than 2's.
See combining code points. People used to think 16 bits would be enough for anyone. Dylan on May 27, root parent next [—]. As a trivial example, case conversions now cover the whole unicode range. Sirine Posted November 16, Posted November 16, Michael Kim Posted November 28, Posted November 28, Pretty good read if you have a few minutes.
You can also index, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, slice and iterate over strings, all operations that you really shouldn't do unless you really now what you are doing.
But inserting a codepoint with your approach would require all downstream bits to be shifted within and across bytes, something that would be a much bigger computational burden. So if you're working in either domain you get a coherent view, the problem being when you're interacting with systems or concepts which straddle the divide or even worse may be in either domain depending on the platform.
I certainly have spent very little time struggling with it. When you use হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ encoding based on integral bytes, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, you can use the hardware-accelerated and often parallelized "memcpy" bulk byte moving hardware features to manipulate your strings.
Arabic character encoding problem
Most of the time however you certainly don't want to deal with codepoints. On top of that implicit coercions have been replaced with implicit broken guessing of encodings for example when opening files. Sometimes হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ code points, but more often it's probably characters or bytes. Why wouldn't this work, apart from already existing applications that does not know how to do this.
It certainly isn't perfect, but it's better than the alternatives. DasIch on May 27, root parent prev next [—]. Then, it's possible to make mistakes when converting between representations, eg getting endianness wrong. This is all gibberish to me, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. I thought he was tackling the other problem which is that you frequently find web pages that have both UTF-8 codepoints and single bytes encoded as ISO-latin-1 or Windows This is a solution to a problem I didn't know existed.
Guessing encodings when opening files is a problem precisely because - as you mentioned - হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ caller should specify the encoding, not just sometimes but always. I have to disagree, I think using Unicode in Python 3 is currently easier than in any language I've used, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.
Python 3 doesn't handle Unicode any better than Python 2, it just made it the default string.
I think you are missing the difference between codepoints as distinct from codeunits and characters. That is held up with a very leaky abstraction হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ means that Python code that treats paths as unicode strings and not as paths-that-happen-to-be-unicode-but-really-arent is broken, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.
That is a unicode string that cannot be encoded or rendered in any Gambang jepag way.
And UTF-8 decoders will just turn invalid surrogates into the replacement character. Let me see if I have this straight. Or is some of my above understanding incorrect. It isn't a position based on ignorance.
The name is unserious but the project is very serious, its writer has responded to a few comments and linked to a presentation of his on the subject[0]. I understand that for efficiency we want this to be as fast as possible. Well, Python 3's unicode support is much more complete. It's often implicit. TazeTSchnitzel on May 27, parent prev next [—], হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.
If you don't know the encoding of the file, how can you decode it? Fortunately it's not something I deal with often but thanks for the info, will stop me getting caught out later. Byte strings can be sliced and indexed no problems because a হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ as such is something you may actually want to deal with.
How is any of that in conflict with my original points? WTF8 exists solely as an internal encoding in-memory representationbut it's very useful there, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. This was gibberish to me too.
Government Girls College Takhatgarh
That's certainly one important source of errors. Many people who prefer Python3's way of handling Unicode are aware of these arguments. Most people aren't aware of that at all and it's definitely surprising. Slicing or indexing into unicode strings is a problem because it's not clear what unicode strings are strings of.
Guessing an encoding based on the locale or the content of the file should be the exception and something the caller does explicitly. Right, ok. PaulHoule on May 27, parent prev next [—]. Coding for variable-width takes more effort, but it gives you a better result. Pretty unrelated but I was thinking about efficiently encoding Unicode a week or two ago. I guess you need some operations to get to those details if you need. Yes, "fixed length" is misguided. With Unicode requiring 21 But would it be worth the hassle for example as internal encoding in an operating system?
Veedrac on May 27, parent next [—]. DasIch on May 28, root parent next [—]. Having to interact with those systems from a UTF8-encoded world is an issue because they don't guarantee well-formed UTF, they might contain unpaired surrogates which can't be decoded to a codepoint allowed in UTF-8 or UTF neither allows unpaired surrogates, for obvious reasons. Cesrate Posted April 19, Posted April 19, edited.
Every term is linked to its definition. The name might throw you off, but it's very much serious. Simple compression can take care of the wastefulness of using excessive space to encode text - so it really only leaves efficiency. An number like 0xd could হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ a code unit meaning as part of a UTF surrogate pair, and also be a totally unrelated Unicode হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ point. When you say "strings" are you referring to strings or bytes?
A character can consist of one or more codepoints. That's just silly, so we've gone through this whole unicode everywhere process so we can stop thinking about the underlying implementation details but the api forces you to have to deal with them anyway. The numeric value of these code units denote codepoints that lie themselves within the BMP, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.
Because we want our encoding schemes to be equivalent, the Unicode code space contains a hole where these so-called surrogates lie, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. Existing software assumed that every UCS-2 character was also a code point, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“. My complaint is that Python 3 is an attempt at breaking as little compatibilty with Python 2 as possible while making Unicode "easy" to use, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.
There's not a ton of local IO, but I've upgraded all my personal projects to Python 3. We would only waste 1 bit per byte, which seems reasonable given just how many problems encoding usually represent.
An interesting possible application for this is JSON parsers. That is the ultimate goal. O 1 indexing of code points হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ not that useful because code points are not what people think of as "characters". Dylan on May 27, parent prev next [—]. Man, what was the drive behind adding that extra complexity to life?! SimonSapin on May 28, parent next [—].
Posted April 22, Cesrate Posted April 22, Posted April 24, Posted April 26, Cesrate Posted May 14, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“, Posted May 14, Michael Kim Posted May 14, Cesrate Posted May 15, Posted May 15, Michael Kim Posted June 11, Posted June 11, Cesrate Posted June 18, Posted À¦¹à¦Ÿ সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ 18, Cesrate Posted July 9, Posted July 9, Michael Kim Posted July 9, Cesrate Posted July 12, Posted July 12, Posted July 16, Michael Kim Posted July 24, Posted July 24, Ac3Ali3n Posted July 30, Posted July 30, Posted August 20, edited.
This was presumably deemed simpler হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ only restricting pairs. Now we have a Python 3 that's incompatible to Python 2 but provides almost no significant benefit, solves none of the large well known problems and introduces quite a few new problems. I get that every different thing character is a different Unicode number code رخ. There Python 2 is only "better" in that issues will probably fly under the radar if you don't prod things too much.
Thanks for explaining. Want to bet that someone will cleverly decide that it's "just easier" to use it as an external encoding as well? It's rare enough to not be a top priority. That is not quite true, in the sense that more of the standard library has been made unicode-aware, and implicit Tiution bangla between unicode and bytestrings have been removed. Ah yes, the JavaScript solution.
On হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“ thought I agree. They failed to achieve both goals. The solution they settled on is weird, but has some useful properties, হট সেকà§à¦¸ à¦à¦¿à¦¡à¦¿à¦“.