Quantcast
Channel: Adobe Community: Message List - XMP SDK
Viewing all articles
Browse latest Browse all 801

Re: Unexpected XMP_Error Invalid UTF-8 data byte

$
0
0

Hi,

 

Input to OpenFile() function needs to be a UTF8 string. "flówér.jpg" is in WinANSI, and needs to be converted to UTF8 string so that OpenFile can correctly find the file.

For example, on Windows OS, you need to define a function as:

 

void WinEncodingToUTF8 ( UINT codePage, const XMP_Uns8 * hostPtr, size_t hostLen, std::string * utf8 )

{

int utf16Len = MultiByteToWideChar ( codePage, 0, (LPCSTR)hostPtr, (int)hostLen, 0, 0 );

std::vector<UTF16Unit> utf16 ( utf16Len, 0 );   // MultiByteToWideChar returns native UTF-16.

 

(void) MultiByteToWideChar ( codePage, 0, (LPCSTR)hostPtr, (int)hostLen, (LPWSTR)&utf16[0], utf16Len );

FromUTF16Native ( &utf16[0], (int)utf16Len, utf8 );

}

 

This function requires a function which is present in the file "UnicodeConversions.cpp". So you need to include a file "source/UnicodeConversions.hpp" in your project.

The sample usage could be:

std::string outputPath;

WinEncodingToUTF8( 1252, (const XMP_Uns8 *)inputFile.c_str(), inputFile.size(), &outputPath );


Viewing all articles
Browse latest Browse all 801

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>