3

IntToStr() function returns string which is Unicode now. I want to convert to AnsiString. Can I use AnsiString(IntToStr(I)) safely?

2 Answers 2

7

Sure. Or you can use IntToAnsiString (written by Dr. Bob):

function IntToAnsiStr(X: Integer; Width: Integer = 0): AnsiString;
begin
   Str(X: Width, Result);
end;
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.