如果定义了Unicode,则无法获取CString变量的所有字符 [英] Unable to get all character of CString variable if Unicode is defined

查看:96
本文介绍了如果定义了Unicode,则无法获取CString变量的所有字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我面临一个奇怪的问题,即使用
将数据库查询转换为CString格式 已定义Unicode.

我举一个简单的例子说明我的问题.

Hi Guys,

I am facing a weird problem to put the database query in CString Format with
Unicode defined.

I am giving a simple example of my problem.

CString str1;
int value = 123;        
str1.Format(_T("select * from Table Where Max > %d"), value);
Getting output only 1st character of entire string.
Output-> "s"  
instead of -> "select * from Table Where Max > 123"



我也尝试过这个,但是它没有得到整数变量并显示如下:



I also tried this one but It''s not getting integer variable and displaying like this:

str1.Format((LPCTSTR)("select * from Table Where Max > %d"), value);
OutPut-> "select * from Table Where Max > %d"



请给我一些解决方案,因为我尝试了所有操作,但没有达到我的目标



Please give me some solution because I tried everything but I didn''t get where I did
mistake.

推荐答案

我自己解决了,实际上我只是犯了傻错误.
在Visual Studio中必须启用一个unicode设置.

解决方法如下:

在Visual Studio中检查以下设置:
I got solved myself actually I just did silly mistake.
There is a one unicode setting has to be enable in Visual Studio.

Here is the solution:

Check the following setting in Visual Studio:
Tools->Options->Debug
Check Display unicode strings checkbox.



谢谢...



Thanks...


这篇关于如果定义了Unicode,则无法获取CString变量的所有字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆