Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Internationalization / December 2006

Tip: Looking for answers? Try searching our database.

Question about Encoding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Franky - 18 Dec 2006 20:47 GMT
I have a Command Prompt window open and select all the characters and copy
them to the clipboard (some are OEM graphics symbols).

I then read them from the clipboard:

str = CType(DataO.GetData(DataFormats.OemText, False), String)

and try to convert them to unicode:

Dim InEncoding As Encoding = Encoding.GetEncoding(437)

Dim OutEncoding As Encoding = Encoding.Unicode

Dim StrAsBytes As Byte() = InEncoding.GetBytes(str)

Dim OutEncodingBytes As Byte() = Encoding.Convert(InEncoding, OutEncoding,
StrAsBytes)

Dim OutEncodingChars As Char() = OutEncoding.GetChars(OutEncodingBytes)

textbox1.text= = New String(OutEncodingChars)

But they do not display correctly.

Can you see what is wrong?

I know a different approach that works so what I'm trying to do here is to
learn something I apparently do not understand now.

Thanks for any enlightment
Aldo Donetti [MS] - 28 Dec 2006 02:02 GMT
Hi Frankie, maybe I'm missing some basic concept on the clipboard, but
assuming your operation of reading its content with DataFormats.OemText is
correct, I think you should already have the string you want stored in
"str" after the following instruction
>>str = CType(DataO.GetData(DataFormats.OemText, False), String)
and that is just based on the fact that the .Net Framework internally
already works with Unicode strings

Please let me know if that is not the case
Aldo

-- This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
| From: " Franky" <frankieNOSPAM@a-znet.com>
| Subject: Question about Encoding
[quoted text clipped - 30 lines]
|
| Thanks for any enlightment
Franky - 29 Dec 2006 03:20 GMT
I show the string in a messagebox and the characters are wrong. I don't have
the example here but a the character that looks like a full block in the
Command window shows as a Greek letter in the messagebox. Similar thing
happed to other graphic characters.

Could the clipboard simply take the bytes from the command window and make
then 16-bit without any other conversion?

I do have a way that works but, I'd like to remove a misunderstanding that I
must have because I don't know why the below code does not work!

Thanks for the reply

> Hi Frankie, maybe I'm missing some basic concept on the clipboard, but
> assuming your operation of reading its content with DataFormats.OemText is
[quoted text clipped - 48 lines]
> |
> | Thanks for any enlightment

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.