Announcement

Collapse
No announcement yet.

Asciiz having unicode

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Asciiz having unicode

    I have this call giving me an unicode string but it is asciiz and has no length param.
    Dare devil as i was i forced it with acode$( peek$(... 4 ) ) and i saw a part of the string.
    I remember me asking this before but i forgot how to succesfully squeeze the unicode string out of the asciiz
    hellobasic

  • #2
    lstrlenw() does not give me a complete string unf.
    hellobasic

    Comment


    • #3
      Use lstrlenW to retrieve the length.
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


      • #4
        Code:
        ' ========================================================================================
        ' Extracts the contents of a null-terminated unicode string, given its address, and
        ' converts it to Ansi. These kind of strings are allocated with CoTaskMemAlloc or IMalloc
        ' and freed with CoTaskMemFree. If the optional parameter CodePage is present, it
        ' represents the code page to be used for the conversion process. If not given, the
        ' default code page for the locale of the executing computer is used.
        ' ========================================================================================
        FUNCTION W2A_ (BYVAL pwstr AS DWORD, OPTIONAL BYVAL nCodePage AS LONG) AS STRING
           LOCAL ln AS LONG
           IF pwstr = %NULL THEN EXIT FUNCTION
           ln = lstrlenW(BYVAL pwstr)
           IF ln THEN FUNCTION = ACODE$(PEEK$(pwstr, ln * 2), nCodePage)
        END FUNCTION
        ' ========================================================================================
        Last edited by José Roca; 10 Jul 2009, 03:17 PM.
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #5
          Thank you, perfect..

          I forgot to use size * 2

          See you next time... for the same question
          hellobasic

          Comment


          • #6
            Minor detail as to read-ability...you may want a constant to indicate "*2" just for future reference so that you remember 1byte vs 2byte "strings"

            Engineer's Motto: If it aint broke take it apart and fix it

            "If at 1st you don't succeed... call it version 1.0"

            "Half of Programming is coding"....."The other 90% is DEBUGGING"

            "Document my code????" .... "WHYYY??? do you think they call it CODE? "

            Comment


            • #7
              Minor detail as to read-ability...you may want a constant to indicate "*2" just for future reference so that you remember 1byte vs 2byte "strings
              Now that you don't have to send email and can submit NFSs on-line, why don't you send in the one I sent in a long time ago via email...

              " Please add a new datatype to directly support Wide Character (Unicode) strings and build automatic support into related functions (eg assignment of string literal to STRINGW data type automatically does the "UCODE$() against it, etc.)"

              .. and get yourself the much-coveted "checkmark?"
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment

              Working...
              X