Home > Back-end >  C SQLite3 UTF8 conversion error occurred while ShiftJIS for help!!!!!!
C SQLite3 UTF8 conversion error occurred while ShiftJIS for help!!!!!!

Time:03-04

Use SQLite3 database

Display the contents of the obtained from the database to read errors in the list, is there any great god can help us see
 
Void CDbBase: : the GetColumnText (sqlite3_stmt * HST, char * text, int nCol) {

Char * dest=new char [1000].
Const unsigned char * SRC=https://bbs.csdn.net/topics/sqlite3_column_text (HST, nCol); Line//カ ラ ム か ら テ キ ス ト gain
If (SRC=https://bbs.csdn.net/topics/=NULL) {
Text [0]='\ 0';
}
The else {
UTF8ToShiftJIS (const char * SRC, dest);//ShiftJis variations in

Int len=strlen (dest) + 1;//long さ
Sprintf_s (text, len, _T (" % s "), "");//the early change
_tcscpy_s (text, len, dest);//char に キ ャ ス ト
The delete [] dest;
}
return;

}

 
BOOL UTF8ToShiftJIS (const char * SRC, char * dest)
{
//utf-8 か ら Unicode に variations in し た occasions の long さ を o め る,
Int iWideLength=: : MultiByteToWideChar (CP_UTF8, 0, SRC, strlen (SRC), NULL, 0).
If (iWideLength==0) return FALSE.
LPWSTR lpWideString=new WCHAR [iWideLength];
Int iLength=0;
If (//utf-8 か ら Unicode に variations in す る,
(: : MultiByteToWideChar (CP_UTF8, 0, SRC, strlen (SRC), lpWideString, iWideLength)==0)
//Unicode か ら set Shift_JIS に variations in し た occasions の long さ を o め る,
| | ((iLength=: : WideCharToMultiByte (CP_ACP, 0, lpWideString iWideLength, NULL, 0, NULL, NULL))==0)
//Unicode か ら set Shift_JIS に variations in す る,
| | (: : WideCharToMultiByte (CP_ACP, 0, lpWideString iWideLength, dest, iLength, NULL, NULL)==0)) {
//variations in に failure
The delete lpWideString;
Return FALSE;
}


CodePudding user response:

Maybe the field content is NULL

CodePudding user response:

Screenshot mean sqlite3_column_text this function performs error? That has nothing to do so and encoding conversion function,
In addition, why to dest variables, if the text in the outer function has allocated memory, the text to UTF8ToShiftJIS directly to the function
  • Related