views:

42

answers:

1

I need to create an EBCDIC string within my javascript and save it into an EBCDIC database. A process on the EBCDIC system then uses the data. I haven't had any problems until I came across the character '¬'. In EBCDIC it is hex value of 5F. All of the usual letters and symbols seem to automagically convert with no problem. Any idea how I can create the EBCDIC value for '¬' within javascript so I can store it properly in the EBCDIC db?

Thanks!

+1  A: 

If "all of the usual letters and symbols seem to automagically convert", then I very strongly suspect that you do not have to create an EBCDIC string in Javascript. The character codes for Latin letters and digits are completely different in EBCDIC than they are in Unicode, so something in your server code is already converting the strings.

Thus what you need to determine is how that process works, and specifically you need to find out how the translation maps character codes from Unicode source into the EBCDIC equivalents. Once you know that, you'll know what Unicode character to use in your Javascript code.

As a further note: every single time I've been told by an IT organization that their mainframe software requires that data be supplied in EBCDIC, that advice has been dead wrong. The fact that there's some external interface means that something in the pile of iron that makes up the mainframe and it's tentacles, something the IT people have forgotten about and probably couldn't find if they needed to, is already mapping "real world" character encodings like Unicode into EBCDIC. How does it work? Well, it may be impossible to figure out.

You might try whether this works: var notSign = "\u00AC";

edit: also: here's a good reference for HTML entities and Unicode glyphs: http://www.elizabethcastro.com/html/extras/entities.html The HTML/XML syntax uses decimal numbers for the character codes. For Javascript, you have to convert those to hex, and the notation in Javascript strings is "\u" followed by a 4-digit hex constant. (That reference isn't complete, but it's pretty easy to read and it's got lots of useful symbols.)

Pointy
You may be correct in suspecting that something is already converting from Unicode to EBCDIC and it's just the ¬ symbol that is not mapped correctly. However, I thought I would try your suggestion of \u00AC and that almost works. It gives me ¬. I think the Unicode is being stored as two bytes and for some reason hex 62 gets added before my not symbol.
RobertParker
Weird. Well, another thing to consider is a possible mapping from the character encoding your client is sending back to the web server to some other Unicode or ISO encoding there, *before* anything gets converted to EBCDIC. Character encoding problems are a gigantic pain in the neck!
Pointy
I agree... a big pain in the neck. Thanks for your time. If I find a worthy solution I'll be sure to post it.
RobertParker
To anyone who cares what I did with this... In investigating further I found that the additional character (Â) is actually in my form at the time that my setter method is called... before even getting to the EBCDIC system. However, the \u00AC correctly only gave me the ¬ symbol in my js. I don't know what causes or exactly what translation causes  to get added. I gave up and just added code in my form's setter method to remove the  if it exists.
RobertParker