An ANSI string is an array of 8 bit characters from the ANSI character set, a superset of the 7 bit ASCII character set, terminated by a binary zero. The ANSI string is primarily used in the C programming language and manipulated by a set of ANSI string functions provided by the C Standard Library. Most questions involving ansistring pertain to transformations to other character sets or other representations such as to UNICODE or std::string in C++.
Questions tagged [ansistring]
54 questions
9
votes
4 answers
Transition to Unicode for an application that handles text files
My Win32 Delphi app analyzes text files produced by other applications that do not support Unicode. Thus, my apps needs to read and write ansi strings, but I would like to provide a better-localized user experience through use of Unicode in GUI. …

Argalatyr
- 4,639
- 3
- 36
- 62
5
votes
2 answers
Delphi XE2 AnsiFormat() and ANSI String constants
Is there a handy Format() function that works only on Ansi strings? Because everytime I use an AnsiString with Format() I get a warning. And no, I don't want Delphi to convert my AnsiStrings back and forth between Wide and Ansi strings. That is just…

Brian Hawk
- 728
- 2
- 12
- 24
4
votes
2 answers
Converting UTF8 to ANSI (ISO-8859-1) in Delphi
I have a question about a code that i have to convert UTF8 strings to ANSI strings. My code works for accents in vowels, but with letter Ñ it doesn't work. The code breaks the string. How can I fix this mistake?
The string I have in UTF8: EDIFICIO…
user5507909
4
votes
3 answers
AnsiString as default for type string in Embarcadero C++ Builder?
I have inherited an old Borland C++ Builder application which I now must migrate to a new development tool. The suggested way to go is with Embarcadero C++ Builder, and from my initial tests it seems like a rather smooth transition.
I do however…

Boise
- 195
- 1
- 7
4
votes
2 answers
AnsiString To Stream
I created the following code:
Function AnsiStringToStream(Const AString: AnsiString): TStream;
Begin
Result := TStringStream.Create(AString, TEncoding.ANSI);
End;
But I'm "W1057 Implicit string cast from 'AnsiString' to 'string'"
There is…

Jhonjhon_123
- 288
- 3
- 12
4
votes
6 answers
AnsiString return values from a Delphi 2007 DLL in a Delphi 2009 application
I have a DLL compiled with D2007 that has functions that return AnsiStrings.
My application is compiled in D2009. When it calls the AnsiString functions, it gets back garbage.
I created a little test app/dll to experiment and discovered that if both…

TrespassersW
- 403
- 7
- 14
3
votes
2 answers
How to convert AnsiString to TBytes and vice versa?
I have an AnsiString and I need to convert it in the most efficient way to a TBytes. How can I do that ?

zeus
- 12,173
- 9
- 63
- 184
3
votes
2 answers
Converting UnicodeString to PAnsiChar in Delphi XE
In Delphi XE I am using the BASS audio library, which contains this function:
function BASS_StreamCreateURL(url: PAnsiChar; offset: DWORD; flags: DWORD;
proc: DOWNLOADPROC; user: Pointer):HSTREAM; stdcall; external bassdll;
The 'url' parameter…

Marek Jedliński
- 7,088
- 11
- 47
- 57
3
votes
2 answers
Converting Integer value into AnsiString in Delphi 2009
IntToStr() function returns string which is Unicode now. I want to convert to AnsiString.
Can I use AnsiString(IntToStr(I)) safely?

user42065
- 31
- 2
- 3
3
votes
1 answer
How to convert AnsiString to UnicodeString in Delphi XE4
exzample code:
var
str1 : String;
str2 : AnsiString;
....
str2 := ....;
str1 := String(str2);
I converted such as above,but it didn't work.i found that some data lost in str1.is there a safe way to convert AnsiString to UnicodeString?

taoxl
- 125
- 1
- 1
- 5
3
votes
2 answers
Assign [array of byte] to a Variant with no Unicode conversion
Consider the following code snippet (in Delphi XE2):
function PrepData(StrVal: string; Base64Val: AnsiString): OleVariant;
begin
Result := VarArrayCreate([0, 1], varVariant);
Result[0] := StrVal;
Result[1] := Base64Val;
end;
Base64Val is a…

James L.
- 9,384
- 5
- 38
- 77
2
votes
2 answers
Delphi: How to encode TIdBytes to Base64 string?
How to encode TIdBytes to Base64 string (not AnsiString) ?
ASocket.IOHandler.CheckForDataOnSource(5);
if not ASocket.Socket.InputBufferIsEmpty then
begin
ASocket.Socket.InputBuffer.ExtractToBytes(data);
// here I need to encode data…

jmp
- 2,456
- 3
- 30
- 47
2
votes
1 answer
Delphi: Unicode->AnsiString, language for non-unicode programs
I have Delphi 2010.
XXX-component uses File_Path:AnsiString. A path can be written in XXX-language. If I set to use XXX-language for non-unicode programs in Windows settings then XXX-component recognize the path but if I set default Windows settings…

maxfax
- 4,281
- 12
- 74
- 120
2
votes
3 answers
Distinguishing between string formats
Having an untyped pointer pointing to some buffer which can hold either ANSI or Unicode string, how do I tell whether the current string it holds is multibyte or not?

forsajt
- 857
- 1
- 7
- 13
2
votes
3 answers
Dll built in Delphi 2010/2009 not compatible to Delphi 7 when an Exception is raised
I've built a dll in Delphi 2010 and it's consumed in my delphi 7 application.
I'm aware of the unicode AnsiString / string matter and according to my tests everything works fine up to the moment that no exception is raised by my delphi 2010…

Danilo Gazzoli
- 31
- 3