473,796 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASCII to PDU convertion and back

Hi,

For my SMS-application I need to be able to send characters with accents
(like é and à). But this doesn't seem to work in Text Mode, so i will need
to do it in PDU Mode.

Does anybody has soem converting routines for that in VB.NET? I need my text
to be converted to a PDU-message, and back (for received messages).

Thansk in advance,

Pieter

Nov 22 '05
20 5107
I'm really having troubles to udnerstand what you exactly need to know...

I'm writing a string all the time.
Some of my routines:

Public Sub PinInsert(ByVal strPin As String)
ModemStatus = enumModemStatus .PinValidation
WriteToComPort( "AT+CPIN=" & strPin & cstCR)
MessageSilent(" Inserting the Pin...")
End Sub

Public Sub SetToTextMode()
ModemStatus = enumModemStatus .TextModeValida tion
WriteToComPort( "AT+CMGF=1" & cstCR)
MessageSilent(" Setting to TextMode...")
End Sub

Public Sub WriteToComPort( ByVal strMessage As String)
SerialPort1.Wri te(strMessage)
End Sub

Public Sub SmsSendNumber(B yVal strNumber As String)
ModemStatus = enumModemStatus .SmsNumberSendi ng
WriteToComPort( "AT+CMGS=" & Chr(34) & strNumber & Chr(34) & cstCR)
End Sub

Public Sub SmsSendMessage( ByVal strMessage As String)
ModemStatus = enumModemStatus .SmsMessageSend ing
WriteToComPort( strMessage & Chr(26))
End Sub
It works really fine with just normal text, but once I begin using accents
the accents don't come through....
strMessage is like this: "hello world" or "érica"

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
DraguVaso <pi**********@h otmail.com> wrote:
I'm not using an API: I'm using VB.NET 2005 with the SerialPort-object, if that is what you mean...


Well, that *is* using an API. Anyway...

Anyway, how are you then writing the data to the port? Are you writing
a byte array, or a string? Either way, what encoding are you using?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #11
I'm really having troubles to udnerstand what you exactly need to know...

I'm writing a string all the time.
Some of my routines:

Public Sub PinInsert(ByVal strPin As String)
ModemStatus = enumModemStatus .PinValidation
WriteToComPort( "AT+CPIN=" & strPin & cstCR)
MessageSilent(" Inserting the Pin...")
End Sub

Public Sub SetToTextMode()
ModemStatus = enumModemStatus .TextModeValida tion
WriteToComPort( "AT+CMGF=1" & cstCR)
MessageSilent(" Setting to TextMode...")
End Sub

Public Sub WriteToComPort( ByVal strMessage As String)
SerialPort1.Wri te(strMessage)
End Sub

Public Sub SmsSendNumber(B yVal strNumber As String)
ModemStatus = enumModemStatus .SmsNumberSendi ng
WriteToComPort( "AT+CMGS=" & Chr(34) & strNumber & Chr(34) & cstCR)
End Sub

Public Sub SmsSendMessage( ByVal strMessage As String)
ModemStatus = enumModemStatus .SmsMessageSend ing
WriteToComPort( strMessage & Chr(26))
End Sub
It works really fine with just normal text, but once I begin using accents
the accents don't come through....
strMessage is like this: "hello world" or "érica"

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
DraguVaso <pi**********@h otmail.com> wrote:
I'm not using an API: I'm using VB.NET 2005 with the SerialPort-object, if that is what you mean...


Well, that *is* using an API. Anyway...

Anyway, how are you then writing the data to the port? Are you writing
a byte array, or a string? Either way, what encoding are you using?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #12
DraguVaso <pi**********@h otmail.com> wrote:
I'm really having troubles to udnerstand what you exactly need to know...
<snip>
Public Sub WriteToComPort( ByVal strMessage As String)
SerialPort1.Wri te(strMessage)
End Sub


Okay, that's the bit I needed to know - you're using whatever encoding
the SerialPort class is providing by default.

Try changing that to ISO-8859-1:

SerialPort1.Enc oding = Encoding.GetEnc oding (28591);

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #13
DraguVaso <pi**********@h otmail.com> wrote:
I'm really having troubles to udnerstand what you exactly need to know...
<snip>
Public Sub WriteToComPort( ByVal strMessage As String)
SerialPort1.Wri te(strMessage)
End Sub


Okay, that's the bit I needed to know - you're using whatever encoding
the SerialPort class is providing by default.

Try changing that to ISO-8859-1:

SerialPort1.Enc oding = Encoding.GetEnc oding (28591);

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #14
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"
.... :-/

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
DraguVaso <pi**********@h otmail.com> wrote:
I'm really having troubles to udnerstand what you exactly need to
know...
<snip>
Public Sub WriteToComPort( ByVal strMessage As String)
SerialPort1.Wri te(strMessage)
End Sub


Okay, that's the bit I needed to know - you're using whatever encoding
the SerialPort class is providing by default.

Try changing that to ISO-8859-1:

SerialPort1.Enc oding = Encoding.GetEnc oding (28591);

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #15
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"
.... :-/

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
DraguVaso <pi**********@h otmail.com> wrote:
I'm really having troubles to udnerstand what you exactly need to
know...
<snip>
Public Sub WriteToComPort( ByVal strMessage As String)
SerialPort1.Wri te(strMessage)
End Sub


Okay, that's the bit I needed to know - you're using whatever encoding
the SerialPort class is providing by default.

Try changing that to ISO-8859-1:

SerialPort1.Enc oding = Encoding.GetEnc oding (28591);

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 22 '05 #16
DraguVaso <pi**********@h otmail.com> wrote:
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"


Do you understand those messages? I don't know the language, I'm
afraid.

Messages without accents shouldn't be affected at all. Print out which
encoding the serial port class is using *before* you set it - that
could be useful information.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #17
DraguVaso <pi**********@h otmail.com> wrote:
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"


Do you understand those messages? I don't know the language, I'm
afraid.

Messages without accents shouldn't be affected at all. Print out which
encoding the serial port class is using *before* you set it - that
could be useful information.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #18
I added three things here:

- The encoding before I change the encoding
- the encoding after the changes
- how I open the port and change the encoding

The "met accenten hé jà bèkes" and the "zonder accenten" are the SMS that I
tryed to send: they are dutch...
Before the SerialPort1.Enc oding = System.Text.Enc oding.GetEncodi ng(28591)

?serialport1.En coding
{System.Text.AS CIIEncoding}
[System.Text.ASC IIEncoding]: {System.Text.AS CIIEncoding}
ASCII: {System.Text.AS CIIEncoding}
asciiEncoding: {System.Text.AS CIIEncoding}
BigEndianUnicod e: {System.Text.Un icodeEncoding}
BodyName: "us-ascii"
ChineseHZ: 52936
CodePage: 20127
CodePageASCII: 20127
CodePageBigEndi an: 1201
CodePageDefault : 0
CodePageDLLKore an: 20949
CodePageGB2312: 20936
CodePageMacGB23 12: 10008
CodePageMacKore an: 10003
CodePageNoMac: 2
CodePageNoOEM: 1
CodePageNoSymbo l: 42
CodePageNoThrea d: 3
CodePageUnicode : 1200
CodePageUTF32: 65005
CodePageUTF32BE : 65006
CodePageUTF7: 65000
CodePageUTF8: 65001
CodePageWindows 1252: 1252
dataItem: {System.Globali zation.CodePage DataItem}
DecoderFallback : {System.Text.De coderReplacemen tFallback}
Default: {System.Text.SB CSCodePageEncod ing}
defaultEncoding : {System.Text.SB CSCodePageEncod ing}
DuplicateEUCCN: 51936
emptyByteArray: {Length=0}
ENC50229: 50229
EncoderFallback : {System.Text.En coderReplacemen tFallback}
EncodingName: "US-ASCII"
encodings: {Length=1}
EUCCN: 936
EUCJP: 51932
EUCKR: 51949
GB18030: 54936
HeaderName: "us-ascii"
InternalSyncObj ect: {Object}
IsBrowserDispla y: False
IsBrowserSave: False
ISCIIAssemese: 57006
ISCIIBengali: 57003
ISCIIDevanagari : 57002
ISCIIGujarathi: 57010
ISCIIKannada: 57008
ISCIIMalayalam: 57009
ISCIIOriya: 57007
ISCIIPanjabi: 57011
ISCIITamil: 57004
ISCIITelugu: 57005
IsMailNewsDispl ay: True
IsMailNewsSave: True
ISO_8859_1: 28591
ISO_8859_8_Visu al: 28598
ISO_8859_8I: 38598
ISO2022JP: 50220
ISO2022JPESC: 50221
ISO2022JPSISO: 50222
ISOKorean: 50225
ISOSimplifiedCN : 50227
IsReadOnly: True
IsSingleByte: True
Latin1: {System.Text.La tin1Encoding}
latin1Encoding: {System.Text.La tin1Encoding}
m_codePage: 20127
m_deserializedF romEverett: False
m_isReadOnly: True
MIMECONTF_BROWS ER: 2
MIMECONTF_MAILN EWS: 1
MIMECONTF_SAVAB LE_BROWSER: 512
MIMECONTF_SAVAB LE_MAILNEWS: 256
s_InternalSyncO bject: {Object}
Unicode: {System.Text.Un icodeEncoding}
unicodeEncoding : {System.Text.Un icodeEncoding}
UTF32: {System.Text.UT F32Encoding}
utf32Encoding: {System.Text.UT F32Encoding}
UTF7: {System.Text.UT F7Encoding}
utf7Encoding: {System.Text.UT F7Encoding}
UTF8: {System.Text.UT F8Encoding}
utf8Encoding: {System.Text.UT F8Encoding}
WebName: "us-ascii"
WindowsCodePage : 1252
After the SerialPort1.Enc oding = System.Text.Enc oding.GetEncodi ng(28591)

?serialport1.En coding
{System.Text.La tin1Encoding}
[System.Text.Lat in1Encoding]: {System.Text.La tin1Encoding}
ASCII: {System.Text.AS CIIEncoding}
asciiEncoding: {System.Text.AS CIIEncoding}
BigEndianUnicod e: {System.Text.Un icodeEncoding}
BodyName: "iso-8859-1"
ChineseHZ: 52936
CodePage: 28591
CodePageASCII: 20127
CodePageBigEndi an: 1201
CodePageDefault : 0
CodePageDLLKore an: 20949
CodePageGB2312: 20936
CodePageMacGB23 12: 10008
CodePageMacKore an: 10003
CodePageNoMac: 2
CodePageNoOEM: 1
CodePageNoSymbo l: 42
CodePageNoThrea d: 3
CodePageUnicode : 1200
CodePageUTF32: 65005
CodePageUTF32BE : 65006
CodePageUTF7: 65000
CodePageUTF8: 65001
CodePageWindows 1252: 1252
dataItem: {System.Globali zation.CodePage DataItem}
DecoderFallback : {System.Text.In ternalDecoderBe stFitFallback}
Default: {System.Text.SB CSCodePageEncod ing}
defaultEncoding : {System.Text.SB CSCodePageEncod ing}
DuplicateEUCCN: 51936
emptyByteArray: {Length=0}
ENC50229: 50229
EncoderFallback : {System.Text.In ternalEncoderBe stFitFallback}
EncodingName: "Western European (ISO)"
encodings: {Length=2}
EUCCN: 936
EUCJP: 51932
EUCKR: 51949
GB18030: 54936
HeaderName: "iso-8859-1"
InternalSyncObj ect: {Object}
IsBrowserDispla y: True
IsBrowserSave: True
ISCIIAssemese: 57006
ISCIIBengali: 57003
ISCIIDevanagari : 57002
ISCIIGujarathi: 57010
ISCIIKannada: 57008
ISCIIMalayalam: 57009
ISCIIOriya: 57007
ISCIIPanjabi: 57011
ISCIITamil: 57004
ISCIITelugu: 57005
IsMailNewsDispl ay: True
IsMailNewsSave: True
ISO_8859_1: 28591
ISO_8859_8_Visu al: 28598
ISO_8859_8I: 38598
ISO2022JP: 50220
ISO2022JPESC: 50221
ISO2022JPSISO: 50222
ISOKorean: 50225
ISOSimplifiedCN : 50227
IsReadOnly: True
IsSingleByte: True
Latin1: {System.Text.La tin1Encoding}
latin1Encoding: {System.Text.La tin1Encoding}
m_codePage: 28591
m_deserializedF romEverett: False
m_isReadOnly: True
MIMECONTF_BROWS ER: 2
MIMECONTF_MAILN EWS: 1
MIMECONTF_SAVAB LE_BROWSER: 512
MIMECONTF_SAVAB LE_MAILNEWS: 256
s_InternalSyncO bject: {Object}
Unicode: {System.Text.Un icodeEncoding}
unicodeEncoding : {System.Text.Un icodeEncoding}
UTF32: {System.Text.UT F32Encoding}
utf32Encoding: {System.Text.UT F32Encoding}
UTF7: {System.Text.UT F7Encoding}
utf7Encoding: {System.Text.UT F7Encoding}
UTF8: {System.Text.UT F8Encoding}
utf8Encoding: {System.Text.UT F8Encoding}
WebName: "iso-8859-1"
WindowsCodePage : 1252
How I open it:
SerialPort1.Por tName = strPortName '"COM1"
SerialPort1.Bau dRate = intBaudRate '9600
SerialPort1.Dat aBits = intDataBits '8
SerialPort1.Par ity = parParity 'Parity.None
SerialPort1.Sto pBits = stbStopBits 'StopBits.One
SerialPort1.Han dshake = hskHandShake 'Handshake.None
SerialPort1.Ope n()
SerialPort1.Enc oding = System.Text.Enc oding.GetEncodi ng(28591)

"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
DraguVaso <pi**********@h otmail.com> wrote:
Thanks, I changed it and tryed to send some messages but I always got this
answer when I got accents in it:

"met accenten hé jà bèkes

OK
"
And not the "+CMGS: " that I normally should receive...

Even messages without accent don't work: there I get this as an answer for
mthe modem:
"zonder accenten

ERROR
"


Do you understand those messages? I don't know the language, I'm
afraid.

Messages without accents shouldn't be affected at all. Print out which
encoding the serial port class is using *before* you set it - that
could be useful information.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #19
DraguVaso <pi**********@h otmail.com> wrote:
I added three things here:

- The encoding before I change the encoding
- the encoding after the changes
- how I open the port and change the encoding

The "met accenten hé jà bèkes" and the "zonder accenten" are the SMS that I
tryed to send: they are dutch...


<snip>

Ah, I see. Well, sending "zonder accenten" should be identical whether
you're using ASCII or ISO-8859-1.

On the other hand, I see you're using an unprintable character at the
end of the text. I'd strongly recommend sending any binary values as
bytes rather than still using the encoding for that.

Given that you're setting it to "text" mode though, I wonder whether
you might not be limited to ASCII anyway - you may need to change
something else to use non-ASCII characters.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
542
by: DraguVaso | last post by:
Hi, For my SMS-application I need to be able to send characters with accents (like é and à). But this doesn't seem to work in Text Mode, so i will need to do it in PDU Mode. Does anybody has soem converting routines for that in VB.NET? I need my text to be converted to a PDU-message, and back (for received messages). Thansk in advance,
24
9074
by: ChaosKCW | last post by:
Hi I am reading from an oracle database using cx_Oracle. I am writing to a SQLite database using apsw. The oracle database is returning utf-8 characters for euopean item names, ie special charcaters from an ASCII perspective. I get the following error: > SQLiteCur.execute(sql, row)
0
9684
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10236
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.