This kind of cat always gets out of the bag eventually.
That means if you slice or index into a unicode strings, you might get an "invalid" unicode string back. TazeTSchnitzel on May 27, বড দà§à¦§ মেয়ে দের খাবো, root parent next [—]. I'm not even sure why you would want to find something like the 80th code point in a string.
The name might throw you off, but it's very much serious. It seems like those operations make sense in either case but I'm sure I'm missing something. I used strings to mean both. Guessing an encoding based বড দà§à¦§ মেয়ে দের খাবো the locale or the content of the file should be the exception and something the caller does explicitly. PaulHoule on May 27, parent prev next [—]. People used to think 16 bits would be enough for anyone.
Download ZIP. Function to fix ut8 special characters displayed as 2 characters utf-8 interpreted as ISO or Windows This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. I guess you need some operations to get to those details if you need. On the guessing encodings when opening files, that's not really a problem.
WTF8 exists solely as an internal encoding in-memory representationbut it's very useful there. Created July 3, Star You must be signed in to star a gist. It might be removed for non-notability. Compatibility with UTF-8 বড দà§à¦§ মেয়ে দের খাবো, I guess?
And unfortunately, I'm not anymore enlightened as to my misunderstanding. Guessing encodings when opening files is a problem precisely because - as you mentioned - the caller should specify the encoding, not just sometimes but always.
A character can consist of one or more codepoints. 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. Why this over, say, À¦¬à¦¡ দà§à¦§ মেয়ে দের খাবো Coding for variable-width takes more effort, but it gives you a better result.
SimonSapin on May 28, parent next [—]. As a trivial example, case conversions now cover the whole unicode range. Why wouldn't this work, apart from already existing applications that does not know how to do this. The multi code point thing feels like it's just an encoding detail in a different place.
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.
Simple compression can take care of the wastefulness of using excessive space to encode text - so it really only leaves efficiency. Because not everyone gets Unicode right, real-world data may contain unpaired surrogates, and WTF-8 is an extension of UTF-8 that handles such data gracefully.
It slices by codepoints? 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.
ISO (ISO Latin 1) Character Encoding
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. When you use an encoding based on integral bytes, বড দà§à¦§ মেয়ে দের খাবো, you can use the hardware-accelerated and often parallelized "memcpy" bulk byte moving বড দà§à¦§ মেয়ে দের খাবো features to manipulate your strings.
Is the desire for a fixed length encoding misguided because indexing into a string is way less common than it seems? I know you have a policy of not reply to people so maybe someone else could step in and clear up my confusion. Man, what was the drive behind adding that extra complexity to life?!
TazeTSchnitzel on May 27, parent prev next [—]. There's no good use case. Therefore, the concept of Unicode scalar value was introduced and Unicode text was restricted to not contain any surrogate code point. Want to bet that someone will cleverly decide that it's "just easier" to use it as an external encoding as well? That is, you can jump to the middle of a stream and find the next code point by looking at no more than 4 bytes.
" " symbols were found while using contentManager.storeContent() API
O 1 indexing of code points is not that useful because code points are not what people think of as "characters". More importantly some codepoints merely modify others and cannot stand on বড দà§à¦§ মেয়ে দের খাবো own. SiVal on May 28, parent prev next [—]. Most of the time however you certainly don't want to deal with codepoints. Slicing or indexing into unicode strings is a problem because it's not clear what unicode strings are strings of.
That is a unicode string that cannot be encoded or rendered in any meaningful way.
You can divide strings appropriate to the use. Pretty unrelated but I was thinking about efficiently encoding Unicode a বড দà§à¦§ মেয়ে দের খাবো or two ago. And I mean, I can't really think of any cross-locale requirements fulfilled by unicode.
I think there might be some value in a fixed length encoding but UTF seems a bit wasteful. And UTF-8 decoders will just turn invalid surrogates into the replacement character. Serious question -- is this a serious project or a joke? I get that every different thing character is a different Unicode number code point. 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 [—]. Dylan on May বড দà§à¦§ মেয়ে দের খাবো, parent prev next [—]. Well, Python 3's unicode support is much more complete. I think you'd lose half of the already-minor benefits of fixed indexing, বড দà§à¦§ মেয়ে দের খাবো, and there would be enough Aliciaosean complexity to leave you worse off.
Sometimes that's code points, but more often it's probably characters or bytes. On further thought Share Filipino wife agree.
Right, ok. As the user of unicode I don't really care about that. Every term is linked to its definition. We would never run out of codepoints, বড দà§à¦§ মেয়ে দের খাবো, and lecagy applications can simple ignore codepoints it doesn't understand. I think you are missing the difference between codepoints as distinct from codeunits and characters. 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.
Share Copy sharable link for this gist. Learn more about clone URLs. Embed What would you like to do? Can someone explain this in laymans terms? If you mean, you are manipulating the process XML and storing that data, then this سكس 🇦🇹🇦🇹 done in a different way, if I am not mistaken. How is any of that in conflict with my original points? Dylan on May 27, root parent next [—]. It's all about the answers! Python however only gives you a codepoint-level perspective.
Code Revisions 1 Stars 12 Forks 7. I don't even know what you are achieving here, বড দà§à¦§ মেয়ে দের খাবো. DasIch on May 28, root parent next [—].
This is all gibberish to me. It's rare enough to not be a top priority. Yes, "fixed length" is misguided. Questions Tags Users Badges.
I can't comment on that. Codepoints and characters are not equivalent. Embed Embed this gist in your website. Or is some of my above understanding incorrect. It also has the advantage of breaking in less random ways than unicode. This was gibberish to me too. This was presumably deemed simpler that only restricting pairs. An interesting possible application for this is JSON parsers.
You বড দà§à¦§ মেয়ে দের খাবো still open it as raw bytes if required. SimonSapin on May 27, parent prev next [—]. I understand that for efficiency we want this to be as fast as possible. That was the piece I was missing.
If I slice characters I expect a slice of characters. Ah yes, the JavaScript solution. Maybe you use the wrong storeContent method or your case is not really covered. Why shouldn't you slice or index them? 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. You can look at unicode strings from different perspectives and see a sequence of codepoints or a বড দà§à¦§ মেয়ে দের খাবো of characters, both can be reasonable depending on what you want to do.
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.
We would only waste 1 bit per byte, which seems reasonable given just how many problems encoding usually represent. The nature of unicode is that there's always a problem you didn't but should know existed.
ISO-8859-1 (ISO Latin 1) Character Encoding
Veedrac on May 27, root parent prev next [—]. 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]. If you don't know the encoding of the file, how can you decode it? Thanks for explaining. Byte বড দà§à¦§ মেয়ে দের খাবো can be sliced and indexed no problems because a byte as such is something you may actually want to deal with.
TazeTSchnitzel on May 27, prev next [—]. Fortunately it's not something I deal with often but thanks for the info, will stop me getting caught out later. See combining code points. The caller should specify the encoding manually ideally.