|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert OEM to Unicodethem to the clipboard. 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? " Franky" <frankieNOSPAM@a-znet.com> schrieb: Take a look at this sample:>I have a Command Prompt window open and select all the characters and copy >them to the clipboard. > [OEM to Unicode] <URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip> -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> I must have seen this example before - some place
because I have tested the statement Encoding.GetEncoding( _ CultureInfo.InstalledUICulture.TextInfo.OEMCodePage _ ).GetString(Encoding.Default.GetBytes(Text)) and it works . My problem is that I must be misunderstanding something because the code I submitted does not work and it seems to me that it should. I'd like to know what is wrong with it. Thanks Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message news:eajvo6rIHHA.2232@TK2MSFTNGP02.phx.gbl... >" Franky" <frankieNOSPAM@a-znet.com> schrieb: >>I have a Command Prompt window open and select all the characters and copy >>them to the clipboard. >> [OEM to Unicode] > > Take a look at this sample: > > <URL:http://dotnet.mvps.org/dotnet/samples/misc/RedirectConsole.zip> > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://dotnet.mvps.org/dotnet/faqs/> I can make it work but don't understand why.
Change from Encoding.Convert(InEncoding, OutEncoding to Encoding.Convert(OutEncoding,InEncoding Doc says Public Shared Function Convert ( _ srcEncoding As Encoding, _ dstEncoding As Encoding, _ bytes As Byte() _ ) As Byte()Here is the way I figure it.The string I get from the clipboard, InStr, is OEM.So InStrAsBytes is an byte array, 1 byte per character. OEMThat is the source array.and InEncoding is the source encoding.But to make it work I have to treat it as the destination encoding.Unless the doc is wrong.Anyone familiar enough with this to correct my analysis?ThanksI have a Command Prompt window open and select all the characters and copy them to the clipboard. I then read them from the clipboard InStr = 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 InStrAsBytes As Byte() = InEncoding.GetBytes(InStr) Dim OutEncodingBytes As Byte() = Encoding.Convert(InEncoding, OutEncoding, InStrAsBytes) Dim OutEncodingChars As Char() = OutEncoding.GetChars(OutEncodingBytes) textbox1.text= = New String(OutEncodingChars) But they do not display correctly. Can you see what is wrong? Scratch the last post. I did NOT work. So I'm back to square one. Why
doesn't the code at the bottom work? What is wrong with it? ....snip bad analysis... Sorry Show quoteHide quote > I have a Command Prompt window open and select all the characters and copy > them to the clipboard. > > I then read them from the clipboard > InStr = 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 InStrAsBytes As Byte() = InEncoding.GetBytes(InStr) > > Dim OutEncodingBytes As Byte() = Encoding.Convert(InEncoding, OutEncoding, > InStrAsBytes) > > Dim OutEncodingChars As Char() = OutEncoding.GetChars(OutEncodingBytes) > > textbox1.text= = New String(OutEncodingChars) > > But they do not display correctly. > > Can you see what is wrong? > >
business layer, data access layer , presentation layer for asp.net using C#.net
Validation Controls video What is the return type of Session("Something")? class types in vb.net Reflection and SetValue .arrrrggggggghhhhh anchoring How to manage a exception in a Aplications Questions, questions...... refactor menu? |
|||||||||||||||||||||||