question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cross-platform way to obtain UTF8 bytes

See original GitHub issue

Currently there is no cross-platform way to convert a String to a UTF8 byte stream or array. I’ve long thought this was a bit silly, since it’s an easy-enough operation in both Java and JS. We currently have ceylon.buffer.charset, but that’s JVM-only, and carries a bunch of baggage.

I think this is a reasonable thing to add to the language module, but where should it go:

  • String itself?
  • process or runtime?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:3
  • Comments:31 (31 by maintainers)

github_iconTop GitHub Comments

3reactions
lucaswerkmeistercommented, Apr 11, 2018

Honestly, I for one would be perfectly happy leaving this in ceylon.buffer.

1reaction
gavinkingcommented, Apr 3, 2018

Well I think with the API I just proposed, performance is going to be just fine

Oh, well now I’m not so sure. There doesn’t seem any way in the java.nio stuff to do character-by-character encoding/decoding without allocating a ByteBuffer and a CharacterBuffer for each character. I suppose that’s just prohibitively slow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UTF8 support on cross platform C application
How do you find it? Just look for the sequence of bytes; you find it at byte offset 2. This is how strstr...
Read more >
How to read utf8 chars/strings from stdin cross-platform?
Now, for reading utf8 I tried reading from stdin byte by byte and checking if the byte indicates a continued utf8 character, but...
Read more >
Text Encodings for Cross-Platform Frameworks | Ruminations
My personal recommendation is to use UTF-8, as it has many helpful properties. For starters, ASCII is a subset of UTF-8, so any...
Read more >
Unicode and UTF-8 functions
Cross -platform function to test a files access() with a UTF-8 encoded name or value. ... Converts UTF-8 string s to a local...
Read more >
UTF-8
UTF-8 is capable of encoding all 1,112,064 valid character code points in Unicode using one to four one-byte (8-bit) code units. Code points...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found