Does AS3 support Extended ASCII Codes?
Copy link to clipboard
Copied
I am working on a Flex project that is interfacing with physical hardware. Using the AS3 command of socket.send I can set a particular feature on the physical hardware. The problem I am having is I need access to send from the Extended ASCII codes. here is an example....
socket.send("l\x7F\x07\r");
This would be translated to me sending two numbers to the hardware. 7F and 07. The Dec equivalent of these Hex codes are 127 and 7. The hardware takes these two numbers and calculates a length along with a third integer.
For example, if I needed to set the length to 1928 I would send the following..
socket.send("l\x88\x07\r"); or 136 + 256 * 7 = 1928
Unfortunately the Hex 88 is in the extended ASCII table. The highest the regular goes up to is 7f which is a Dex of 127.I need the ability to send full 0 to 255 numbers in ASCII form. I can't send from 128-255 without using the codes from the ASCII extended table. I get an error every time I try to send something form the extended ASCII table back from the hardware.
Can anyone confirm that AS3 does not support the Extended ASCII codes?
Here is a link to the code for regular ASCII and the extended. http://www.tutorialspoint.com/html/ascii_table_lookup.htm
Thanks.

Copy link to clipboard
Copied
The docs say ASCII codes are supported using \xnn, but you can clearly create a string using escape sequences with values greater than 127. The problem may lie somewhere in the socket to server chain. How does your socket class send the data? How many bytes does the server expect to receive?
Here's a little test - don't know if it applies to your situtation:
var s:String;
var ba:ByteArray = new ByteArray();
// test using ByteArray.writeUTF
s = "l\x7F\x07\r";
ba.length=0;
ba.writeUTF(s);
trace(s, "\nlength:", s.length, "\nbytes length:", ba.length, "\n========================\n")
s = "l\x7F\x07\r";
ba.length=0;
ba.writeUTF(s);
trace(s, "\nlength:", s.length, "\nbytes length:", ba.length, "\n========================\n")
// test using ByteArray.writeMultiByte
s = "l\x7F\x07\r";
ba.length=0;
ba.writeMultiByte(s,"ASCII");
trace(s, "\nlength:", s.length, "\nbytes length:", ba.length, "\n========================\n")
s = "l\x88\x07\r";
ba.length=0;
ba.writeMultiByte(s,"ASCII");
trace(s, "\nlength:", s.length, "\nbytes length:", ba.length, "\n========================\n")
// what's in the ByteArray
ba.position=0;
while(ba.bytesAvailable)
{
trace("Pos:",ba.position, "Value:", ba.readByte())
}

