Windows XP 和 7 中的 CString 格式问题和差异?
有一个问题,下面的代码适用于 Windows 7 而不适用于 Windows XP?无论如何,你知道其中的原因吗?提前致谢。我已经检查过这不是数据库错误。
对于 Win 7,它返回存储的内容,对于 Win XP 也是如此。但是,XP 中的格式化将 CString 设置为 ""
。
if(getDB()->getEncoding() == IDatabase::UTF8){
a_value.Format(_T("%s"), sqlite3_column_text(getCommand()->getStatement(), idx));
}else{
a_value.Format(_T("%s"), sqlite3_column_text16(getCommand()->getStatement(), idx));
}
另外,我们确信这不是 unicode 问题。
There is a problem, below code works for Windows 7 and not for Windows XP? By any chance, do you know the reason for that? Thanks in advance. I have checked that it is not a DB error.
For Win 7 it returns what is stored, also the same case for Win XP. But, Formatting in XP sets CString as ""
.
if(getDB()->getEncoding() == IDatabase::UTF8){
a_value.Format(_T("%s"), sqlite3_column_text(getCommand()->getStatement(), idx));
}else{
a_value.Format(_T("%s"), sqlite3_column_text16(getCommand()->getStatement(), idx));
}
Also, we are sure that it is not a unicode issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这看起来确实不是 Windows 问题。您确定您没有在有效版本和无效版本之间进行不同的构建吗?
上面的代码是有问题的,因为如果您执行 Unicode 构建,
sqlite3_column_text()
将返回错误类型的字符串。对于 Unicode 构建,您需要使用sqlite3_column_text16()
。This really doesn't appear to be a Windows issue. Are you sure you're not doing different builds between the version that works and the one that doesn't?
The code above is problematic because if you do a Unicode build,
sqlite3_column_text()
will return the wrong type of string. For Unicode builds, you'd wantsqlite3_column_text16()
instead.检查编译期间配置的字符集在两个平台上是否相同
unicode
或多
字节
也许有帮助,再见
check if character set configured during compilation is the same on the two platform
unicode
or
multibyte
maybe it helps, bye