TEXT()函数有什么作用? [英] what does TEXT() function do?

查看:277
本文介绍了TEXT()函数有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我在我的代码中使用了TEXT()函数:

hi everybody. i have used TEXT() function in my code in such a way:

TEXT("some text")



将char *转换为wchar_t。

有没有将常量字符串替换为变量的方法?


to convert a char* to wchar_t.
is there any way to replace the constant string to a variable?

char *cAdress=NULL;
cAdress = (char *)alloca(aAdress.size() + 1);
memcpy(cAdress, aAdress.c_str(), aAdress.size() + 1);
TEXT(cAdress);

推荐答案

如果需要将文本从ASCII转换为Unicode(并且反之亦然)在你的程序中你需要使用所描述的适当的转换函数在此MSDN部分 [ ^ ]。
If you need to convert text from ASCII to Unicode (and vice versa) within your program then you need to use the appropriate conversion functions as described in this MSDN section[^].


在编译期间由预处理程序指令定义UNICODE时,将字符串标识为Unicode。否则,宏将字符串标识为ANSI字符串。

请看这里: http://msdn.microsoft.com/en-us/library/windows/desktop/dd374074%28v=vs.85%29.aspx [<一个href =http://msdn.microsoft.com/en-us/library/windows/desktop/dd374074%28v=vs.85%29.aspxtarget =_ blanktitle =New Window> ^ ]



此处讨论了类似的问题:将char *转换为wchar * [ ^ ]
Identifies a string as Unicode when UNICODE is defined by a preprocessor directive during compilation. Otherwise, the macro identifies a string as an ANSI string.
Please look here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd374074%28v=vs.85%29.aspx[^]

A similar question has been discussed here:Convert char * to wchar*[^]


我认为它是一个MACRO,而不是一个功能。



它如果项目是unicode,将字符串文字转换(识别)为unicode,如果项目不是unicode,字符串将保持不变



看看在MSDN文档中(http:// m sdn.microsoft.com/en-us/library/windows/desktop/dd374074(v=vs.85).aspx)



例如,它会让你将普通的ANSI字符串传递给接收unicode字符串的函数。
I think it is a MACRO, not a function.

It will convert ("identify") a string literal to unicode if the project is unicode, if the project is not unicode, the string will stay the same

Have a look at the MSDN documentation ( http://msdn.microsoft.com/en-us/library/windows/desktop/dd374074(v=vs.85).aspx)

for example, It will let you pass a normal ANSI string to a function that receives a unicode string.


这篇关于TEXT()函数有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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