Progrider

Programming discussion

Search

Searches topics and replies. Every word has to appear in the post.

8 posts found.

PostPosted
Findings · post #4

Yes. maxlength and JS length both. For most text you'd never notice. It's names, and anyone using emoji, that hit it.


by ines
Findings · post #3

So my maxlength on the HTML form is counting UTF-16 units?


by sam
Findings · post #2

Rust's s.len() is bytes, chars().count() is code points, and graphemes need a crate. At least it's obvious you're choosing.


by ferrous
Findings · post #1

Third bug report this year from a form that "limits names to 20 characters". 'é'.length is 2 in JS (e + combining accent), while 'é' typed as one code point is 1. They look identical. Most emoji are 2, because length counts UTF-16 units. T…


by ines
Help · post #4

That fixed it, thanks both! José is back.


by bea
Help · post #3

And keep newline="" on that open() call if you're using the csv module.


by lintroller !-TjZOnKc
Help · post #2

Nothing wrong, Excel is guessing. Without a BOM it assumes the Windows codepage when you double click a CSV. Use encoding="utf-8-sig" and it'll write the three BOM bytes at the start, and Excel will then read it as UTF-8. Don't use it for f…


by ines
Help · post #1

My class list has names like José and Zoë. I write it from Python with open("list.csv", "w", encoding="utf-8") and LibreOffice shows it correctly. On the school computers with Excel it shows José. What did I do wrong?


by bea
All times shown in UTC.