Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

convert ansi to unicode

phph Member Posts: 393
is it possible in vb, and how?
[red]ph[/red][blue][/blue][red]t[/red]
[red]http://fade.to/phet[/red]
[blue]12d.hypermart.net[/blue]
[red]toadthefreak@hotmail.com[/red]

Comments

  • ColdShineColdShine Member Posts: 597
    [code]
    [blue]Dim[/blue] strUnicode [blue]As String[/blue], strAnsi [blue]As String[/blue]
    strUnicode = "In VB, all strings are Unicode by default"
    strAnsi = StrConv(strUnicode, vbFromUnicode)
    [green]' Now strAnsi contains the ANSI version of strUnicode,
    ' use it as needed.[/green]
    ...
    [green]' Convert back now.[/green]
    strUnicode = StrConv(strAnsi, vbUnicode)
    [/code]
    Note that VB will keep thinking strAnsi is Unicode, so Len(strAnsi) will return half the actual length; if you (in debug mode) look at the value of strAnsi, you will see a "?????????????????????", because VB will get pairs of ANSI characters and try to display them as single Unicode charaters.
    As an example, "AB" in ANSI (&H41 &H42), will be the Unicode char &H4241, which will probably be an unknown character and thus displayed as "?".
    ________________
    [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b][/size]

  • BarkeeperBarkeeper Member Posts: 335
    : is it possible in vb, and how?
    : [red]ph[/red][blue][/blue][red]t[/red]
    : [red]http://fade.to/phet[/red]
    : [blue]12d.hypermart.net[/blue]
    : [red]toadthefreak@hotmail.com[/red]
    :

    Yes, it is possible, but with ugly code.

    check the MSDN for the StrConv-Function with the vbFromUnicode and vbUnicode Flags

    ------------------------------------------
    Only stupidity of mankind and the universe
    are infinite, but i'm not sure concerning
    the universe. A. Einstein

  • ColdShineColdShine Member Posts: 597
    : Yes, it is possible, but with ugly code.

    Which is the code you've seen? Look at mine two posts above, it's clean sky...
    ________________
    [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b][/size]

  • BarkeeperBarkeeper Member Posts: 335
    : : Yes, it is possible, but with ugly code.
    :
    : Which is the code you've seen? Look at mine two posts above, it's clean sky...
    : ________________
    : [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b][/size]
    :
    :

    as you mentioned in your other post: The Problem is the Len-Function. The ugly code i've seen has to do with byte-arrays containing the string to manipulate. check out "Hardcore Visual Basic" by Bruce McKinney (you can find it on the Internet) - Chapter 2.
    ------------------------------------------
    Only stupidity of mankind and the universe
    are infinite, but i'm not sure concerning
    the universe. A. Einstein

  • ColdShineColdShine Member Posts: 597
    : as you mentioned in your other post: The Problem is the Len-Function. The ugly code i've seen has to do with byte-arrays containing the string to manipulate. check out "Hardcore Visual Basic" by Bruce McKinney (you can find it on the Internet) - Chapter 2.

    Oh, now I understand. You read HVB, too. Then I agree with your definition of "ugly code". The problem, there, is the plenty of almost-impossible things uncle Bruce tries to achieve. My answer is a few more than 1/100 of what McKinney wrote in his book: it is [b]only[/b] a bidirectional conversion from ANSI to Unicode.
    ________________
    [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b][/size]

  • Shawn CarterShawn Carter Member Posts: 0

    _______ < http://forcoder.org /> free ebooks and video tutorials about [ Scratch, Go, Perl, Assembly, JavaScript, Visual Basic .NET, Delphi, MATLAB, Visual Basic, Java, PHP, Swift, Python, R, C, PL/SQL, Objective-C, Ruby, C++, C# COBOL, Bash, Prolog, VBScript, SAS, Scala, ABAP, Scheme, F#, LabVIEW, Ada, Erlang, Fortran, Alice, Awk, Lisp, Julia, Clojure, Kotlin, Transact-SQL, Dart, ML, Apex, D, Rust, Logo, Crystal, Hack, FoxPro, Lua ] ____

Sign In or Register to comment.