Shop OBEX P1 Docs P2 Docs Learn Events
Using Javascript "charCodeAt" to read string characters sent by Spinneret — Parallax Forums

Using Javascript "charCodeAt" to read string characters sent by Spinneret

highplainsbubbahighplainsbubba Posts: 34
edited 2012-10-07 15:19 in Accessories
I managed to figure out my own problem so I thought I would share it in case others had the same issue. I was using the Spinneret to read a DIO card that sent the status of inputs by serial bus using hex. If all 8 inputs were on, it would send a ÿ character (Hex 255) to the Spinneret. I then sent that character to the browser and used Javascript "charCodeAt" to get the hex value of that character. That worked great for everything less that $7F (the standard ASCII character set 0-127) but it wouldn't display the character code for characters in the ASCII control code range above $7F (128-255). After a lot of research, I found this webpage http://www.w3schools.com/tags/ref_urlencode.asp

W
hich stated :

URLs can only be sent over the Internet using the ASCII character-set.Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format.
URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.

URLs cannot contain spaces. URL encoding normally replaces a space with a + sign.

I will have to convert the character codes to hex at the Spinneret and then send the hex value to the browser. I
Sign In or Register to comment.