最佳答案:
const
n: WideString = ''; //n=Nothing
s := n+#$0061+#$0301;
这解决了我下面的所有情况,否则会失败。
唯一可行的变体是将其声明为常量:
AccentAcute: WideString = #$0301;
AccentAcute: WideString = WideChar($0301);
AccentAcute: WideString = WideChar(#$0301);
AccentAcute: WideString = WideString(#$0301);
样品用法:
s := 'Pasta'+AccentAcute;
不起作用的基于常量的语法
AccentAcute: WideString = $0301;
不兼容的类型
AccentAcute: WideString = #0301;
给
AccentAcute: WideString = WideString($0301);
无效的类型转换
AccentAcute: WideString = WideString(#$0301);
无效的类型转换
AccentAcute: WideChar = WideChar(#0301);
给Pastai
AccentAcute: WideChar = WideChar($0301);
给Pasta´
其他失败的语法
'Pasta'+WideChar($0301)
给Pasta´
'Pasta'+#$0301
给Pasta´
WideString('Pasta')+#$0301
给
我发现的所有基于常量的语法的总结:
AccentAcute: WideString = #$0301; //works
AccentAcute: WideString = WideChar(#$0301); //works
AccentAcute: WideString = WideString(#$0301); //works
AccentAcute: WideString = $0301; //incompatble types
AccentAcute: WideString = WideChar($0301); //works
AccentAcute: WideString = WideString($0301); //invalid typecast
AccentAcute: WideChar = #$0301; //fails, gives Pasta´
AccentAcute: WideChar = WideChar(#$0301); //fails, gives Pasta´
AccentAcute: WideChar = WideString(#$0301); //incompatible types
AccentAcute: WideChar = $0301; //incompatible types
AccentAcute: WideChar = WideChar($0301); //fails, gives Pasta´
AccentAcute: WideChar = WideString($0301); //invalid typecast
WideChar
只要您只附加到一个变量,重新排列就可以工作
//Works
t := '0123401234012340123';
t := t+WideChar(#$D840);
t := t+WideChar(#$DC00);
//fails
t := '0123401234012340123'+WideChar(#$D840);
t := t+WideChar(#$DC00);
//fails
t := '0123401234012340123'+WideChar(#$D840)+WideChar(#$DC00);
//works
t := '0123401234012340123';
t := t+WideChar(#$D840)+WideChar(#$DC00);
//works
t := '';
t := t+WideChar(#$D840)+WideChar(#$DC00);
//fails; gives junk
t := ''+WideChar(#$D840)+WideChar(#$DC00);
//crashes compiler
t := WideString('')+WideChar(#$D840)+WideChar(#$DC00);
//doesn't compile
t := WideChar(#$D840)+WideChar(#$DC00);
绝对打击编译器的废话;未经过全面测试的案例。是的,我认识大卫,我们应该升级。