As I am porting an RSA library from ruby to Dart, I have get the corresponding ASCII-8-BIT value of an integer. Dart only has ASCII with representations from 0 to 127, so how can I get the other 128 characters?
Asked
Active
Viewed 853 times
1 Answers
2
ASCII only has 128 characters (http://en.wikipedia.org/wiki/ASCII). There is no 8-bit ASCII.
There are lots of different extensions of ASCII that use the top 128 characters of a byte as well, sometimes called "code pages". The most common (at least in English languaged settings) are Latin-1 and Windows-1252.
For what you are doing, you probably want the LATIN1
codec from "dart:convert".

lrn
- 64,680
- 7
- 105
- 121
-
Thanks, I should have put more clearly that I just wanted the ruby ASCII-8-Bit representation (I know ASCII is default 7-Bit). But thanks a lot, that's the encoding I'm looking for! – Adracus Jan 08 '15 at 13:03
-
Ah, yes, found a reference for Ruby ASCII-8BIT. It's basically binary data with no interpretation of the top 128 characters (they are just numbers). To make that a Unicode string, you need to pick an interpretation of those bytes, and LATIN-1 is the simplest an often the correct one for that (The byte 0xa5 represents the Unicode character U+00a5, so it's extremely simple). – lrn Jan 08 '15 at 13:16