Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
_TITLE and extended ASCII characters.
#12
@Pete

You've used the wrong function. You don't want UnicodeToAnsi. You want AnsiToUnicode. Also, you have to grab the whole string, not just part of it. You want all of it to be converted to Unicode.


Code: (Select All)
Declare Dynamic Library "user32"
    Function SetWindowTextW (ByVal Handle As _Offset, title$)
End Declare

Do: Loop Until _WindowHandle

result = SetWindowTextW(_WindowHandle, ANSIToUnicode(Chr$(240) + " Foo"))

$If UNICODETOANSI = UNDEFINED Then
    $Let UNICODETOANSI = DEFINED
    Declare CustomType Library
        Function WideCharToMultiByte& (ByVal CodePage As _Unsigned Long, Byval dwFlags As Long, Byval lpWideCharStr As _Offset, Byval cchWideChar As Integer, Byval lpMultiByteStr As _Offset, Byval cbMultiByte As Integer, Byval lpDefaultChar As _Offset, Byval lpUsedDefaultChar As _Offset)
        Function MultiByteToWideChar& (ByVal CodePage As _Unsigned Long, Byval dwFlags As Long, Byval lpMultiByteStr As _Offset, Byval cbMultiByte As Integer, Byval lpWideCharStr As _Offset, Byval cchWideChar As Integer)
    End Declare

    Function UnicodeToANSI$ (buffer As String)
        Dim As String ansibuffer: ansibuffer = Space$(Len(buffer))
        Dim As Long a: a = WideCharToMultiByte(437, 0, _Offset(buffer), Len(buffer), _Offset(ansibuffer), Len(ansibuffer), 0, 0)
        UnicodeToANSI = Mid$(ansibuffer, 1, InStr(ansibuffer, Chr$(0)) - 1)
    End Function

    Sub UnicodeToANSI (buffer As String, __dest As String)
        Dim As String ansibuffer: ansibuffer = Space$(Len(buffer))
        Dim As Long a: a = WideCharToMultiByte(437, 0, _Offset(buffer), Len(buffer), _Offset(ansibuffer), Len(ansibuffer), 0, 0)
        __dest = Mid$(ansibuffer, 1, InStr(ansibuffer, Chr$(0)) - 1)
    End Sub

    Function ANSIToUnicode$ (buffer As String)
        Dim As String unicodebuffer: unicodebuffer = Space$(Len(buffer) * 2)
        Dim As Long a: a = MultiByteToWideChar(65001, 0, _Offset(buffer), Len(buffer), _Offset(unicodebuffer), Len(unicodebuffer))
        ANSIToUnicode = unicodebuffer
    End Function

    Sub ANSIToUnicode (buffer As String, __dest As String)
        Dim As String unicodebuffer: unicodebuffer = Space$(Len(buffer) * 2)
        Dim As Long a: a = MultiByteToWideChar(65001, 0, _Offset(buffer), Len(buffer), _Offset(unicodebuffer), Len(unicodebuffer))
        __dest = unicodebuffer
    End Sub
$End If

Besides, I think we have to do some special stuff to enable Unicode display on the title bar. I'll have to dig through my code archives to find the one I've used for displaying foreign characters.
Tread on those who tread on you

Reply


Messages In This Thread
_TITLE and extended ASCII characters. - by Pete - 11-15-2022, 04:25 PM
RE: _TITLE and extended ASCII characters. - by SpriggsySpriggs - 11-15-2022, 08:08 PM



Users browsing this thread: 19 Guest(s)