Utf8ToOemBuffer

See Also: OemToUtf8Buffer, Free, String Functions

Purpose

Converts a UTF-8 string to OEM.

Return Type

String

Syntax

Use CharTranslate.pkg

 

(Utf8ToOemBuffer( {pUtf8Buf}, {iLen} ))

Where:

What It Does

Returns a pointer to a newly allocated string buffer containing the converted text. Converts a string of UTF-8 characters to OEM.

Examples

// Translate data. pass: Data and translation mode.

//     Returns pointer to new translated data 0 if no translation needed.

//     Passed data is not changed.

// eXlt can be: xtUtf8toOem, xtOemtoUtf8 and xtNoTranslate

 

Function TranslateData Integer eXlt Pointer aData Integer iDataLen Returns Pointer

    Pointer aDataXlt

   

    Case Begin

        case (eXlt = xtUtf8toOem)

            Move (Utf8toOemBuffer(aData, iDataLen)) to aDataXlt

            case Break

        case (eXlt = xtOemtoUtf8)

            Move (OemToUtf8Buffer(aData, iDataLen)) to aDataXlt

            case Break

        case else

            Move 0 to aDataXlt

    Case End

   

    Function_Return aDataXlt

End_Function

Notes

Utf8ToOemBuffer will allocate a new block of memory to store the converted string. A pointer to this memory is returned by the function. You must call Free to de-allocate this memory when it is no longer required. Failure to do this will cause a memory leak in your application.