|
-
Aug 28th, 2007, 01:41 PM
#1
Thread Starter
New Member
Code Pages
Hello! How can I send to printer, by use SerialPort, string with
different code pages?
For example:
SerialPort1.WriteLine("textOne") - I need send it in 1250 CodePages,
SerialPort1.WriteLine("textTwo") - I need send it in 1253 CodePages,
SerialPort1.WriteLine("textThree") - I need send it in 1254 CodePages.
If I send it from DOS windows (cmd) by "copy file.txt com1" all is ok,
but if I send it from VB.NET2005 - is problem 
File "file.txt" contain sequence to print string on a printer.
Could you help me?
Regards, Jacek
-
Aug 28th, 2007, 01:47 PM
#2
Re: Code Pages
What is the error that you get?
-
Aug 28th, 2007, 02:07 PM
#3
Thread Starter
New Member
Re: Code Pages
Hi,
I send following string:
SerialPort1.WriteLine("ślimak z łąki") and I see on a label printer after
send from VB:
"?limak z ??ki".
After send from DOS window (cmd) I see correct string:
"ślimak z łąki"
Code page in my country is 1250.
Jacek
Last edited by JacekP; Aug 28th, 2007 at 02:11 PM.
-
Aug 28th, 2007, 03:23 PM
#4
Re: Code Pages
JacekP,
The problem is that the default encoding for strings sent through the serial port in VB.NET is ASCIIEncoding, which is only ASCII text. Anything it can't convert to ASCII comes through as ? as you see on your label.
Convert to UTF or Unicode and you should be in good shape.
Try this before sending any data through the serial port:
Code:
SerialPort1.Encoding = System.Text.Encoding.UTF8
That should do it. If it doesn't work correctly, try one of these alternative supported encodings.
Code:
SerialPort1.Encoding = System.Text.Encoding.Unicode
SerialPort1.Encoding = System.Text.Encoding.UTF32
-
Aug 29th, 2007, 12:43 AM
#5
Thread Starter
New Member
Re: Code Pages
Thank you
"ąćżźśłó" - is correct
I wrote: SerialPort1.Encoding = System.Text.Encoding.GetEncoding(1250)
Regards, Jacek
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|