Beja Expert Licensed User Longtime User Jan 17, 2017 #1 Hi all.. Maybe this is not related 100% to b4x.. but I have a b4a app that will send sms to vb6 PC application through gsm modem.. the message is in Arabic هذا اختبار or this is a test. everything is ok, except that the string is displayed in the vb app as a long line of bytes (double the length of the text). The text is 10 characters but the byte string is 20 هذا اختبار = 06 47 06 30 06 27 00 20 06 27 06 2E 06 2A 06 28 06 27 06 31 Any advice appreciated
Hi all.. Maybe this is not related 100% to b4x.. but I have a b4a app that will send sms to vb6 PC application through gsm modem.. the message is in Arabic هذا اختبار or this is a test. everything is ok, except that the string is displayed in the vb app as a long line of bytes (double the length of the text). The text is 10 characters but the byte string is 20 هذا اختبار = 06 47 06 30 06 27 00 20 06 27 06 2E 06 2A 06 28 06 27 06 31 Any advice appreciated
ilan Expert Licensed User Longtime User Jan 17, 2017 #2 https://www.b4x.com/android/forum/threads/b4x-bytes-to-file.70111/#content
S sorex Expert Licensed User Longtime User Jan 17, 2017 #3 as that string ain't build of regular ascii chars I bets it's sending them as UTF16 codes. so 2 bytes for 1 char.
as that string ain't build of regular ascii chars I bets it's sending them as UTF16 codes. so 2 bytes for 1 char.
udg Expert Licensed User Longtime User Jan 17, 2017 #4 @sorex was faster than me..eheh Look here for Unicode's arabic set of chars. udg
Beja Expert Licensed User Longtime User Jan 17, 2017 #5 sorex said: as that string ain't build of regular ascii chars I bets it's sending them as UTF16 codes. so 2 bytes for 1 char. Click to expand... Yeah.. 2 bytes for each char. it seems like no easy solution.
sorex said: as that string ain't build of regular ascii chars I bets it's sending them as UTF16 codes. so 2 bytes for 1 char. Click to expand... Yeah.. 2 bytes for each char. it seems like no easy solution.
udg Expert Licensed User Longtime User Jan 17, 2017 #6 Yeah.. 2 bytes for each char. it seems like no easy solution. Click to expand... Well, since you know beforehand that the message is in arabic, just drop the first byte of each couple and add it again on the receiving side. I guess that you have to convert spaces (00 20) to 061D (or any other unused char) before "dropping".
Yeah.. 2 bytes for each char. it seems like no easy solution. Click to expand... Well, since you know beforehand that the message is in arabic, just drop the first byte of each couple and add it again on the receiving side. I guess that you have to convert spaces (00 20) to 061D (or any other unused char) before "dropping".
KMatle Expert Licensed User Longtime User Jan 18, 2017 #7 This should work: Code: Copy Dim b As Byte() = System.Text.Encoding.Unicode.GetBytes(value)
Beja Expert Licensed User Longtime User Jan 19, 2017 #8 KMatle said: This should work: Code: Copy Dim b As Byte() = System.Text.Encoding.Unicode.GetBytes(value) Click to expand... Hi KMatle. Is this vb syntax? The b4a side is ok, and here's the problem: 1- b4a app sends SMS to a gsm modem 2- gsm modem sends the sms to vb app 3- if sms is n English then no problem, the English text appear correctly in vb text box 4- if sms is in Arabic then the modem converts each letter (char) to 2 bytes and a long array of bytes equal to the sms length * 2 is sent vb app. Required: to convert the byte array back to Arabic text using vb. Looks like a puzzle sorry. Last edited: Jan 19, 2017
KMatle said: This should work: Code: Copy Dim b As Byte() = System.Text.Encoding.Unicode.GetBytes(value) Click to expand... Hi KMatle. Is this vb syntax? The b4a side is ok, and here's the problem: 1- b4a app sends SMS to a gsm modem 2- gsm modem sends the sms to vb app 3- if sms is n English then no problem, the English text appear correctly in vb text box 4- if sms is in Arabic then the modem converts each letter (char) to 2 bytes and a long array of bytes equal to the sms length * 2 is sent vb app. Required: to convert the byte array back to Arabic text using vb. Looks like a puzzle sorry.
KMatle Expert Licensed User Longtime User Jan 19, 2017 #9 Beja said: Is this vb syntax? Click to expand... Yes. If you have access to the vb code of the program?
Beja said: Is this vb syntax? Click to expand... Yes. If you have access to the vb code of the program?
Beja Expert Licensed User Longtime User Jan 19, 2017 #10 Thanks so much.. Sorry forgot to mention vb6. The code: Code: Copy Dim b As Byte() = System.Text.Encoding.Unicode.GetBytes(value) Doesn't work in vb6.. Last edited: Jan 19, 2017
Thanks so much.. Sorry forgot to mention vb6. The code: Code: Copy Dim b As Byte() = System.Text.Encoding.Unicode.GetBytes(value) Doesn't work in vb6..
KMatle Expert Licensed User Longtime User Jan 20, 2017 #11 Browse the www, There are a lot of examples like this: http://stackoverflow.com/questions/5182102/vb6-vbscript-change-file-encoding-to-ansi
Browse the www, There are a lot of examples like this: http://stackoverflow.com/questions/5182102/vb6-vbscript-change-file-encoding-to-ansi
Beja Expert Licensed User Longtime User Jan 21, 2017 #12 Nothing in www for this problem.. to convert 2 bytes to 1 char Unicode (06 28) to the letter ب There's the conversion table though https://en.wikipedia.org/wiki/Arabic_script_in_Unicode
Nothing in www for this problem.. to convert 2 bytes to 1 char Unicode (06 28) to the letter ب There's the conversion table though https://en.wikipedia.org/wiki/Arabic_script_in_Unicode
Ohanian Active Member Licensed User Longtime User Jan 21, 2017 #13 Hi, Code: Copy http://www.cryptosys.net/pki/manpki/pki_stringstobytes.html http://www.freevbcode.com/ShowCode.asp?ID=6462 http://www.cnblogs.com/Waver/archive/2008/08/28/1279015.html
Hi, Code: Copy http://www.cryptosys.net/pki/manpki/pki_stringstobytes.html http://www.freevbcode.com/ShowCode.asp?ID=6462 http://www.cnblogs.com/Waver/archive/2008/08/28/1279015.html
Beja Expert Licensed User Longtime User Jan 21, 2017 #14 This is the problem. 1- I send to thank you Hebrew (תודה) or arabic (شكرا) the modem connected directly to the computer. 2- The modem relays the message to the vb6 application like this (Hebrew תודה) 05:40 :02-20" 05EA0 5D505D305D Now I want to return the above array (and crlf..etc) back to תודה
This is the problem. 1- I send to thank you Hebrew (תודה) or arabic (شكرا) the modem connected directly to the computer. 2- The modem relays the message to the vb6 application like this (Hebrew תודה) 05:40 :02-20" 05EA0 5D505D305D Now I want to return the above array (and crlf..etc) back to תודה
Beja Expert Licensed User Longtime User Feb 3, 2017 #15 Thanks to all, VB controls cannot handle Unicode by design, so the only solution is coming back to B4J.. thanks AnyWare Software and the people behind it.
Thanks to all, VB controls cannot handle Unicode by design, so the only solution is coming back to B4J.. thanks AnyWare Software and the people behind it.