Results 1 to 5 of 5

Thread: OemTOutf16Buffer throws Illegal Datatype Conversion 4381

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Cayman Islands
    Posts
    3,969

    Default OemTOutf16Buffer throws Illegal Datatype Conversion 4381

    Just got a message from the office and free wifi in Tampa is awful so I don't expect to be able to dig out the answer.

    Point 1, though, OemToUtf16Buffer isn't in the help but OemToUtf8Buffer is.

    below is updated

    ...
    Dave,

    I keep getting illegal datatype conversion error when I run RprNightBreit2. The function that gives me the error is in the screenshot below. It is in CharTranslate.pkg.

    Code:
    //Converts a OEM string to UTF-16
    //pOemBuf    = Pointer to OEM string
    //iLen       = Length of OEM string in bytes
    //Returns pointer to UTF-16 string, use free() to deallocate buffer when it's no longer needed
    Function OemToUtf16Buffer Global Pointer pOemBuf Integer iLen Returns Pointer
        Pointer pWideBuf
        Integer iWideBufLen
        Move 0 to pWideBuf
        Move (MultiToWideBuffer(CP_OEMCP,pOemBuf,iLen,AddressOf(pWideBuf))) to iWideBufLen
        If (iWideBufLen=0) Begin
            Function_Return 0
        End
        Function_Return pWideBuf
    End_Function
    called from

    Code:
        Function OemToUtf16String Global String sSource Integer iBlockUTF16 Returns String //Will's version
         String sDestination
         Address pDest pConverted
         Boolean bVoid
         ZeroString 2 to sDestination    //was 2048
         Move (AddressOf(sDestination)) to pDest
         Move (OemToUtf16Buffer(AddressOf(sSource), CStringLength(sSource))) to pConverted
         Move (MemCopy(pDest,pConverted,iBlockUTF16)) to bVoid    //was 2048
         If (not(bVoid)) Begin
              Showln "failed to convert " sSource
         End
         Move (Free(pConverted)) to bVoid
         Function_Return sDestination
        End_Function
    and OEMtoUTF16String is called from the StartReport

    Code:
            Move 0 to icount
            Direct_Input channel 8 sFile //reopen ascii workfile
     
            Repeat
                ZeroString 1 to sLineIn
                ZeroString 1 to sLineOut
                Read_Block channel 8 sLineIn  1 //iBlockASCII
                Increment iCount
                If (sLIneIn<>sNUL) Begin
                    Move (OemToUtf16string(sLineIn, 1)) to sLineOut
                    Get BinaryFileWrite of oFilesystem iFile (&sLineOut) to bVoid
                    If (not(bVoid)) Begin
                        Send UserError ("Write failed at character #" *(String(icount)))
                        Procedure_Return
                    End
                End
            Until (sLIneIn=sEOF or sLIneIn=sNUL)
    D
    Last edited by DaveR; 7-Sep-2022 at 08:00 AM.
    I should be on a beach ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •