Home > Software engineering >  The Format function
The Format function

Time:09-27

//get NX installation path
Char * translation;
UF_translate_variable (" UGII_ROOT_DIR ", & amp; Translation);


//the ini file and TXT file path
Cstrings BaseDIR1;
BaseDIR1. The Format (L "% s", translation);


Why always BaseDIR1 garbled?

CodePudding user response:

If the project is multi-byte encoding, the value of the translation must be ANSI code, which is the local code, or GB2312, GBK Unicode project, if it is the value of the translation must be a Unicode, you should be here coding issues, the value of the translation may be UTF8 encoding, guess? !

CodePudding user response:

UF_translate_variable the function requirements of the parameter is the char type or wchar type? You debug it and see after UF_translate_variable (" UGII_ROOT_DIR ", & amp; Translation); Later, the inside of the translation is just what I knew where I went wrong

CodePudding user response:

BaseDIR1. The Format (L "% s", A2W (translation));

Have a try

CodePudding user response:

Cstrings BaseDIR1; BaseDIR1=translation;

CodePudding user response:

//NX installation path 
TCHAR * translation;
UGII_ROOT_DIR UF_translate_variable (_T (" "), & amp; Translation);


//the ini file and TXT file path
Cstrings BaseDIR1;
BaseDIR1. The Format (_T (" % s "), translation);



建议楼主打开include\tchar.h一眼,

CodePudding user response:

//method 1 (not necessarily apply to all versions of cstrings: MTC/ATL/WTL, please test whether it is feasible to) 
Char * translation;
UF_translate_variable (" UGII_ROOT_DIR ", & amp; Translation);
Cstrings BaseDir1 (translation);

//method 2 (not necessarily apply to all versions of the cstrings: MTC/ATL/WTL, please test whether it is feasible to)
Char * translation;
UF_translate_variable (" UGII_ROOT_DIR ", & amp; Translation);
Cstrings BaseDir1=translation;

//method 3 (in general all cstrings version)
Char * translation;
UF_translate_variable (" UGII_ROOT_DIR ", & amp; Translation);
Cstrings BaseDir1;
LPTSTR lpszBuffer=BaseDir1. GetBuffer (1024);
Wsprintf (lpszBuffer, TEXT (" % hs "), translation);
BaseDir1. ReleaseBuffer ();

CodePudding user response:

L "% s"

Coding system chaos, string have a L, in a short while not
Don't use L, using _T (" ABC ")

CodePudding user response:

The problem of character set.
1, the engineering character set into a multibyte
2, if is a Unicode byte, can use when the format MultiByteToWideChar transformation
  • Related