Click here to Skip to main content
15,888,102 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi every body,
How to write unicode on teminal screen? Can you help me, please? tks all so much.........
I'm using Serial Port class and i have serialPort.Write("ê"). But it show to teminal screen a charater Ω :D
Posted
Updated 22-Jun-14 16:22pm
v2
Comments
Sergey Alexandrovich Kryukov 22-Jun-14 23:38pm    
Do you mean console application? It has nothing to do with serial port where you can write any bytes you wish. But with console, you need to actually see the characters rendered with some font, which is possible, but with some limitations...

What is actually transmitted to a serial port when you pass a character, depends on current encoding, of course. What it was in your case?

—SA

1 solution

This isn't a question we can answer simply: it may not even be possible.

If you mean that you have a terminal as in a VDT (a dumb terminal device such as a VT220, or similar) connected to your PC via a serial port (RS232 or similar) then it is going to depend on exactly what the terminal itself can display, and exactly how you tell it to do that. I know of no terminal that uses Unicode (heck, I didn't know they still made VDTs!) - they all used ASCII in my day, which may present a solution to your problem.
Instead of sending your data to the terminal as a string, send it as a byte array instead, and use ASCII encoding instead of Unicode:
C#
string s = "Hello!\r\n'être et avoir' is a French documentary, made in 2002";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(s);
mySerialPort.Write(bytes, 0, bytes.Length);
I don't guarantee it will work for all characters you need, but it stands a better chance!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900