IntToStr() function returns string which is Unicode now. I want converting to AnsiString. Can I use AnsiString(IntToStr(I)) safely?
+6
A:
Sure. Or you can use IntToAnsiString (written by Dr. Bob):
function IntToAnsiStr(X: Integer; Width: Integer = 0): AnsiString;
begin
Str(X: Width, Result);
end;
gabr
2008-12-05 08:05:12
I hope Dr. Bob will write this function for c++ builder too...
mhd
2008-12-31 03:24:36
A:
Yes, you can safely convert the UnicodeString returned by IntToStr to an AnsiString. The reason it's safe is that the string it returns will only contain the digit characters '0' through '9', not any fancy Unicode digits, so the conversion to AnsiString will not lose any information.
Rob Kennedy
2008-12-05 15:06:28