SMS App to vb

Beja

Expert
Licensed User
Longtime User
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
 

sorex

Expert
Licensed User
Longtime User
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
@sorex was faster than me..eheh
Look here for Unicode's arabic set of chars.

udg
 

Beja

Expert
Licensed User
Longtime User
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.

Yeah.. 2 bytes for each char. it seems like no easy solution.
 

udg

Expert
Licensed User
Longtime User
Yeah.. 2 bytes for each char. it seems like no easy solution.

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".
 

Beja

Expert
Licensed User
Longtime User
This should work:

B4X:
Dim b As Byte() = System.Text.Encoding.Unicode.GetBytes(value)

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:

Beja

Expert
Licensed User
Longtime User
Thanks so much.. Sorry forgot to mention vb6.
The code:
B4X:
Dim b As Byte() = System.Text.Encoding.Unicode.GetBytes(value)
Doesn't work in vb6..
 
Last edited:

Ohanian

Active Member
Licensed User
Longtime User
Hi,

B4X:
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
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
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.
jSolution.png
 
Top