{"action":"created","issue":{"url":"https://api.github.com/repos/inexorabletash/text-encoding/issues/40","labels_url":"https://api.github.com/repos/inexorabletash/text-encoding/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/inexorabletash/text-encoding/issues/40/comments","events_url":"https://api.github.com/repos/inexorabletash/text-encoding/issues/40/events","html_url":"https://github.com/inexorabletash/text-encoding/issues/40","id":108212291,"number":40,"title":"CP437 Encoder/Decoder","user":{"login":"tracker1","id":444316,"avatar_url":"https://avatars.githubusercontent.com/u/444316?v=3","gravatar_id":"","url":"https://api.github.com/users/tracker1","html_url":"https://github.com/tracker1","followers_url":"https://api.github.com/users/tracker1/followers","following_url":"https://api.github.com/users/tracker1/following{/other_user}","gists_url":"https://api.github.com/users/tracker1/gists{/gist_id}","starred_url":"https://api.github.com/users/tracker1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tracker1/subscriptions","organizations_url":"https://api.github.com/users/tracker1/orgs","repos_url":"https://api.github.com/users/tracker1/repos","events_url":"https://api.github.com/users/tracker1/events{/privacy}","received_events_url":"https://api.github.com/users/tracker1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-09-24T20:53:57Z","updated_at":"2015-09-25T00:16:49Z","closed_at":"2015-09-24T22:37:20Z","body":"Just thinking it would be nice to have a CP437 (IBM US-DOS Extended ASCII) convertors available.\r\n\r\nThere have been a number of projects to convert ansi/ascii art for display in modern UTF systems... It would be a nice to have feature if this were available here... I'm not sure about the format used in the `lib/encoding-indexes.js` file... Is the array simply a mapping of position X to character code/pair Y?  Does this start at the byte value of 1 (skipping null)?  And am I correct in assuming I can go all the way from character 1 through 255, and does null mean don't map, or default map?\r\n\r\nI'd be happy to make a PR if these questions could be clarified... possibly adding comments as to the structure of the `encoding-indexes` in the file itself."},"comment":{"url":"https://api.github.com/repos/inexorabletash/text-encoding/issues/comments/143086805","html_url":"https://github.com/inexorabletash/text-encoding/issues/40#issuecomment-143086805","issue_url":"https://api.github.com/repos/inexorabletash/text-encoding/issues/40","id":143086805,"user":{"login":"inexorabletash","id":771547,"avatar_url":"https://avatars.githubusercontent.com/u/771547?v=3","gravatar_id":"","url":"https://api.github.com/users/inexorabletash","html_url":"https://github.com/inexorabletash","followers_url":"https://api.github.com/users/inexorabletash/followers","following_url":"https://api.github.com/users/inexorabletash/following{/other_user}","gists_url":"https://api.github.com/users/inexorabletash/gists{/gist_id}","starred_url":"https://api.github.com/users/inexorabletash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inexorabletash/subscriptions","organizations_url":"https://api.github.com/users/inexorabletash/orgs","repos_url":"https://api.github.com/users/inexorabletash/repos","events_url":"https://api.github.com/users/inexorabletash/events{/privacy}","received_events_url":"https://api.github.com/users/inexorabletash/received_events","type":"User","site_admin":false},"created_at":"2015-09-25T00:16:49Z","updated_at":"2015-09-25T00:16:49Z","body":"The existing indexes are defined in the Encoding Standard, https://encoding.spec.whatwg.org/#indexes\r\n\r\nBasically the index for an encoding is a resource to make the decoder/encoder `handler` something other than a huge switch statement.\r\n\r\nThe decoder handler just takes the input byte (or bytes) does math to get an index pointer, and looks up index[pointer]. For CP437 you could just have 256 entries (the 95 printable ASCII ones would have value == index) or you could be more clever and do math to avoid those 95 values. I'd keep it simple, honestly.\r\n\r\nThe encode handler does the reverse - looks up the Unicode code point in the table (inefficiently!), and if found it returns the corresponding index, then does math to convert that to a byte. Again, if you go with a simple 256 entry table then it's just the index itself as the output byte.\r\n\r\nHope that helps!"}}