Sending text in UniCode format | Search |
NowSMS Support Forums ⬆ NowSMS Support - SMS Issues ⬆ Archive through May 12, 2004 ⬆ |
◄ ► |
Author | Message | |||
James Unregistered guest |
Hi, I read in one of the threads that text can be sent in a binary SMS using Unicode format (with the DCS set to 8). It says that in order to send the string 'text' the data needs to be '0074006500730074' (with DCS set to 8) I was wondering how this encoding is done? I am trying to do this in Java using the bytes[] = myString.toBytes("UTF-8"), but I just get a random sequence such as '[B@1486306' returned. Thanks James | |||
Bryce Norwood - NowSMS Support Board Administrator Username: Bryce Post Number: 2320 Registered: 10-2002 |
James, There is a small typo in that other message thread. The encoding shown is for the string "test" (not "text"). But that is a minor nit. I'm not an expert in Java, but the Unicode representation in the example is a representation where each character is converted into a 4 digit hex value with its character representation. That is different from UTF-8 encoding. I do have some JavaScript that I have used in the past for converting a text string into a hex string of Unicode characters. function decToHex(decimal) { var temp = parseInt(decimal,10); var hex = ""; while (temp > 15) { remainder = temp % 16; hex = getHexDigit(remainder) + "" + hex temp = parseInt(temp / 16); } if (temp >= 0) { hex = getHexDigit(temp) + "" + hex } else { return 0; } return hex; } The script below is excerpted from a routine that was processing a text string that was entered into a form variable named "msgText". The string "hexText" receives the hex string of Unicode characters. var hexText = ""; for (var i = 0; (i < document.forms[0].msgText.value.length)); i++) { var tempStr = decToHex(document.forms[0].msgText.value.charCodeAt(i)); while (tempStr.length < 4) { tempStr = "0" + tempStr; } hexText = hexText + tempStr; } This is not exactly what you're looking for, but you could experiment with this and probably adapt it easily enough ... | |||
James Unregistered guest |
Hi Bryce, Thanks, I'll give that a go. Incidently, is there any plan to provide this functionality in future versions of NowSMS. Reading the various threads recently posted, I think quite a few people might find it useful. Cheers, James | |||
Bryce Norwood - NowSMS Support Board Administrator Username: Bryce Post Number: 2347 Registered: 10-2002 |
James, NowSMS does this automatically. It parses the message text to determine if the text can be represented with just the GSM 7-bit character set, or if Unicode has to be used. If the text cannot be represented in GSM 7-bit, it is automatically sent in Unicode format. Perhaps there is something else that you are trying to accomplish? If so, please explain. -bn |