在设置字符串之后,我试图从字符串中获取一个特殊字符(ASCII >127),但是输出发生了变化,因为CharToStr接受uchar,而StringGetChar返回ushort。
这是我尝试过的:
uchar uch = 234;
Print(uch); //Output: 234
string a = CharToStr(uch);
uch = (uchar)StringGetChar(a,0);
Print(uch); //Output: 218
我如何克服这个问题?
发布于 2019-07-22 00:41:12
我想提出我自己的答案。而不是处理uchar <==> ushort
,这是由于MQL4中持续的错误造成的问题,您可以这样重新编码它:
//let's say it can be any number, unknown in compilation time
string msg = "234My message";
//then somewhere in the code when you want to display the message:
uchar arrow = (uchar)StringToInteger(StringSubstr(msg,0,3));
//and act upon this arrow, now that you have the correct code:
if(arrow==234) { ... }
else if (arrow==233) { ... }
https://stackoverflow.com/questions/57048963
复制相似问题