我有一个简单的问题。如何在 Delphi - 7 中将 WideChar
转换为 2xByte
?我在互联网上搜索了StackOverflow但没有结果...
最佳答案
David给了你更好的方式,即,
var
b1, b2: Byte;
wc: WideChar;
...
b1 := WordRec(wc).Lo;
b2 := WordRec(wc).Hi;
其他一些选项(只是为了好玩):
b1 := Lo(Word(wc));
b2 := Hi(Word(wc));
和
b1 := Byte(wc);
b2 := Byte(Word(wc) shr 8);
和
b1 := PByte(@wc)^;
b2 := PByte(NativeUInt(@wc) + 1)^;
和
var
wc: WideChar;
bytes: WordRec absolute wc;
begin
// Magic! The bytes are already found in bytes.Lo and bytes.Hi!
关于delphi - WideChar 转换为字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15388183/