我有一个包含许多非 ASCII 字符的 excel 文件,我想用空格字符替换它们。
此文本将被输入到 MySQL 数据库中,并且不会在字符串中包含这些字符。我HY000 Incorrect string value
在尝试发布该行时得到一个。
我有一个包含许多非 ASCII 字符的 excel 文件,我想用空格字符替换它们。
此文本将被输入到 MySQL 数据库中,并且不会在字符串中包含这些字符。我HY000 Incorrect string value
在尝试发布该行时得到一个。
如果非 Ascii 字符集是固定的,您可以使用:
NewString := StringReplace(OriginalString,#1#4,' ',[rfReplaceAll])
其中 #1#4 是您要替换的非 ascii 字符。
你也可以这样做。
function StripNonAlpha(aInput : String) : String;
var
I : Integer;
begin
result := aInput;
for I := 1 to length(result) do
begin
if not CharInSet(result[I],['A'..'Z','a'..'z']) then
result[I] := ' ';
end;
end;
然后您可以将 CharInSet 中的 Set 更改为可接受的字符。