Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Marc Weustink
Felipe Monteiro de Carvalho wrote: > On 10/20/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: >> This should be >>WideText := GetMem(Size*2); >> because you get the number of characters, and the number of bytes 2* >> number of >> characters. > > Thanks, it works, but I still have doubts. > >

Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Felipe Monteiro de Carvalho
Ok, I looked at the source code of Utf8ToUnicode and I can answer some of my questions: 3) Shouldn´t we allocate Size * 2 + 2? I mean, we did not allocate space for the null-terminator. Utf8ToUnicode returns a size that already counts the extra null-terminator it appends to the string. 4) He

Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Vincent Snijders
Felipe Monteiro de Carvalho schreef: On 10/20/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: This should be WideText := GetMem(Size*2); because you get the number of characters, and the number of bytes 2* number of characters. Thanks, it works, but I still have doubts. First of all, I

Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Felipe Monteiro de Carvalho
On 10/20/06, Vincent Snijders <[EMAIL PROTECTED]> wrote: This should be WideText := GetMem(Size*2); because you get the number of characters, and the number of bytes 2* number of characters. Thanks, it works, but I still have doubts. 1) On linux I will need that cwstring unit, right? This w

Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Vincent Snijders
Felipe Monteiro de Carvalho schreef: Hello, I am having a problem with string conversion from utf-8 to utf-16: procedure TForm1.Button6Click(Sender: TObject); var WideText: PWideChar; AText: string; Size: Integer; begin AText := 'Meu longo texto iso-8859-1'; Size := Utf8ToUnicode(nil, PCha

Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Vincent Snijders
Felipe Monteiro de Carvalho schreef: On 10/20/06, Marco van de Voort <[EMAIL PROTECTED]> wrote: Did you include cwstring as first unit in your project? Oh, that doesn´t work. I forgot to mention I am on Windows, where this unit isn´t available. And isn't needed. The windows system unit does

Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Felipe Monteiro de Carvalho
On 10/20/06, Marco van de Voort <[EMAIL PROTECTED]> wrote: Did you include cwstring as first unit in your project? Oh, that doesn´t work. I forgot to mention I am on Windows, where this unit isn´t available. -- Felipe Monteiro de Carvalho ___ fpc-pas

Re: [fpc-pascal] Problem with string conversion

2006-10-20 Thread Felipe Monteiro de Carvalho
On 10/20/06, Marco van de Voort <[EMAIL PROTECTED]> wrote: Did you include cwstring as first unit in your project? thanks, I didn't know I had to. -- Felipe Monteiro de Carvalho ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists

Re: [fpc-pascal] Problem with string conversion

2006-10-19 Thread Marco van de Voort
> I am having a problem with string conversion from utf-8 to utf-16: > > procedure TForm1.Button6Click(Sender: TObject); > var > WideText: PWideChar; > AText: string; > Size: Integer; > begin > AText := 'Meu longo texto iso-8859-1'; > Size := Utf8ToUnicode(nil, PChar(AText), 0); > Wide