Skip to main content
14 events
when toggle format what by license comment
Aug 4, 2015 at 7:40 comment added Jodrell To get the alphabet position you could just do c & 0x1F, this is case insensitive and just as readable as c - 96.
Aug 3, 2015 at 11:50 comment added deworde I would really prefer to wrap "int numberOfChar = byteRepresentation - 96;" into its own function, getNumberFromChar(), just because it's a dirty little implementation detail which will break on edge cases such as other languages; being able to encapsulate that complexity has value.
Aug 3, 2015 at 11:25 comment added Ismael Miguel @Jodrell You are correct. Excuse my mistake. Unicode also has UTF-16 and UTF-32. I mixed up the names.
Aug 3, 2015 at 11:14 comment added Jodrell @IsmaelMiguel, annoying gripe but Unicode is a superset of ASCII, UTF-8 is a way of encoding Unicode.
Aug 3, 2015 at 11:12 comment added Jodrell @GeorgePhillipson, 'a' does indeed have a decimal value of 97. You can use this to avoid writing lots of code. Whilst this mapping is unlikely to change, it is still an implementation detail that others will need to know to understand your code. If you use this you should comment accordingly so other developers understand, or learn.
Aug 3, 2015 at 11:04 comment added Ismael Miguel I see my comment passed the wrong idea. What I was trying to say is that the ASCII table you linked is only for the first 128 characters, but that there were made different extended versions with other characters. Something I didn't said before: utf-8 is a superset of ASCII, which means that this will work on a utf-8 string.
Aug 3, 2015 at 11:04 comment added Jodrell I think you need range checking or a special case for names that include say an apostrophe ('\'') like an Irish name. These could otherwise result in negative values.
Aug 3, 2015 at 10:55 history edited Jens CC BY-SA 3.0
added 33 characters in body
Aug 3, 2015 at 10:48 comment added Jens @IsmaelMiguel yeah, good point!
Aug 3, 2015 at 10:47 comment added Ismael Miguel Notice that the provided ASCII table only has the first 127 characters. There's the extended version that has some variants to include other glyphs(?) and accents and other weird characters (like ç).
Aug 3, 2015 at 10:44 comment added Jens @GeorgePhillipson yeah. that's something i learned in a c lession. check this image out: upload.wikimedia.org/wikipedia/commons/thumb/1/1b/… As you can see. it is the ascii table.
Aug 3, 2015 at 10:32 comment added George Phillipson Hi Jens I never knew that a = 97 etc, that is something new I have learned today.
Aug 3, 2015 at 10:16 review First posts
Aug 3, 2015 at 10:46
Aug 3, 2015 at 10:11 history answered Jens CC BY-SA 3.0