Clipboard OEMText is confusing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • **Developer**

    #1

    Clipboard OEMText is confusing

    If I open a Command Prompt window and with the Alt key enter 222 then 223
    then 224 so the window shows ???

    If I then copy that to the clipboard and in my program do

    Case DataFormats.Oem Text
    Dim bDataO As DataObject = Clipboard.GetDa taObject()
    If bDataO.GetDataP resent(DataForm ats.OemText, False) Then
    Editor1.Text = CType(bDataO.Ge tData(DataForma ts.OemText, False), String)
    End If

    I get some symbol I don't know followed by a beta followed by an "a" with a
    dot over it.

    I'd expect to get the same symbols that show in the Command window.
    I don't know why I expect that except that I thought the Command wondow was
    like DOS and DOS used OEM?

    I'd appreciate a few works of enlightment.

    Would you expect to see what I see or what I expected to see?

    Why?



    Thanks in advance for any helpful rempl.


  • Herfried K. Wagner [MVP]

    #2
    Re: Clipboard OEMText is confusing

    " **Developer**" <REMOVEdevelope r@a-znet.com> schrieb:[color=blue]
    > If I open a Command Prompt window and with the Alt key enter 222 then 223
    > then 224 so the window shows ???
    >
    > If I then copy that to the clipboard and in my program do
    >
    > Case DataFormats.Oem Text
    > Dim bDataO As DataObject = Clipboard.GetDa taObject()
    > If bDataO.GetDataP resent(DataForm ats.OemText, False) Then
    > Editor1.Text = CType(bDataO.Ge tData(DataForma ts.OemText, False), String)
    > End If
    >
    > I get some symbol I don't know followed by a beta followed by an "a" with
    > a dot over it.
    >
    > I'd expect to get the same symbols that show in the Command window.
    > I don't know why I expect that except that I thought the Command wondow
    > was like DOS and DOS used OEM?[/color]

    Maybe an auto-conversion from DOS-OEM to Unicode is done and characters are
    interpreted the wrong way. Untested:

    \\\
    Imports System.Globaliz ation
    Imports System.Text
    ..
    ..
    ..

    ''' <summary>
    ''' Konvertiert den Text in <paramref name="Text"/> von der DOS-
    ''' Codepage (OEM) in die Windows-Codepage (ANSI).
    ''' </summary>
    ''' <param name="Text">Tex t, der konvertiert werden soll.</param>
    ''' <returns>
    ''' Der Text aus <paramref name="Text"/> in der aktuellen Windows-
    ''' Codepage.
    ''' </returns>
    Private Function ConvertFromOem( ByVal Text As String) As String
    Return _
    Encoding.GetEnc oding( _
    CultureInfo.Ins talledUICulture .TextInfo.OEMCo dePage _
    ).GetString(Enc oding.Default.G etBytes(Text))
    End Function
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • **Developer**

      #3
      Re: Clipboard OEMText is confusing

      >[color=blue]
      > Maybe an auto-conversion from DOS-OEM to Unicode is done and characters
      > are interpreted the wrong way. Untested:
      >[/color]
      Guess it's tested now - works for me - Thanks

      This is what I tried but it didn't work.
      Do you see what is wrong with it?
      Called with 437

      Public Shared Function GetCodePageStri ng(ByVal str As String, ByVal codePage
      As Integer) As String

      Dim OutEncoding As Encoding = Encoding.GetEnc oding(codePage)

      Dim InEncoding As Encoding = Encoding.Unicod e

      Dim StrAsBytes As Byte() = InEncoding.GetB ytes(str)

      Dim OutEncodingByte s As Byte() = Encoding.Conver t(InEncoding, OutEncoding,
      StrAsBytes)

      Dim OutEncodingChar s(lOutEncoding. GetCharCount(Ou tEncodingBytes, 0,
      OutEncodingByte s.Length)) As Char

      GetCodePageStri ng = New String(OutEncod ingChars)

      End Function




      Comment

      • **Developer**

        #4
        Re: Clipboard OEMText is confusing

        I also interchanged the definition of OutEncoding and InEncoding
        Still did not work


        " **Developer**" <REMOVEdevelope r@a-znet.com> wrote in message
        news:%23osFs6Ty FHA.1856@TK2MSF TNGP12.phx.gbl. ..[color=blue][color=green]
        > >
        >> Maybe an auto-conversion from DOS-OEM to Unicode is done and characters
        >> are interpreted the wrong way. Untested:
        >>[/color]
        > Guess it's tested now - works for me - Thanks
        >
        > This is what I tried but it didn't work.
        > Do you see what is wrong with it?
        > Called with 437
        >
        > Public Shared Function GetCodePageStri ng(ByVal str As String, ByVal
        > codePage As Integer) As String
        >
        > Dim OutEncoding As Encoding = Encoding.GetEnc oding(codePage)
        >
        > Dim InEncoding As Encoding = Encoding.Unicod e
        >
        > Dim StrAsBytes As Byte() = InEncoding.GetB ytes(str)
        >
        > Dim OutEncodingByte s As Byte() = Encoding.Conver t(InEncoding, OutEncoding,
        > StrAsBytes)
        >
        > Dim OutEncodingChar s(lOutEncoding. GetCharCount(Ou tEncodingBytes, 0,
        > OutEncodingByte s.Length)) As Char
        >
        > GetCodePageStri ng = New String(OutEncod ingChars)
        >
        > End Function
        >
        >
        >
        >[/color]


        Comment

        Working...