• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How can output filename include UTF8 Text?

Enthusiast ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

My code output text to 1 file:

If FileName not include UTF8 Text (Ex: 1.html), it output OK,

But FileName include UTF8 Text  (Ex: 名称未設定-1.indd_1.html), it can't create file.

How can output filename include UTF8 Text?

 

WideString strContent=WideString("test名称未設定");

PMString filename="C:/Users/pc1/Desktop/cc/名称未設定-1.indd_1.html";

std::string utf8StdStr;
StringUtils::ConvertWideStringToUTF8(strContent, utf8StdStr);

std::string strfile;
StringUtils::ConvertWideStringToUTF8(WideString(filename), strfile);

std::ofstream fileOut(strfile);

if (!fileOut)
{
ASSERT_FAIL("ofstream failed.");
break;
}
fileOut << utf8StdStr;
fileOut.close();

TOPICS
SDK

Views

191

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

Hello,

Shouldn't your filename be

"C:\\Users\\pc1\\Desktop\\cc\\名称未設定-1.indd_1.html"

instead ?

Also, did you try saving to a basic folder, in case there are user rights permissions issues with saving to the desktop ?

Very best regards,

Olivier

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

It can create file, but filename output not correct:

Input: 名称未設定-1.indd_1.html

Output: ヨシマ誇「ム旁ィ-1.indd_1.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

Try pre-pending it with L.

L"C:\\Users\\pc1\\Desktop\\cc\\名称未設定-1.indd_1.html"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 06, 2022 Apr 06, 2022

Copy link to clipboard

Copied

LATEST

I had try, but occur error:

Error C2440 'initializing': cannot convert from 'const wchar_t [56]' to 'PMString' 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines