Recent

Author Topic: WideString to AnsiString conversion  (Read 43033 times)

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1947
Re: WideString to AnsiString conversion
« Reply #15 on: June 20, 2013, 02:51:19 pm »
It's really so. String which contains cyrillic as well as other signs like ü correctly transforms to readable Ansi string which contains Ansi cyrillic letters as well as "u", not "?" sign.

Then it is not ANSI. Or is there a ANSI (8bit) Codepage which contains cyrillic AND Umlauts (öäü)?
http://de.wikipedia.org/wiki/Windows-1251

plashenkov

  • New Member
  • *
  • Posts: 24
Re: WideString to AnsiString conversion
« Reply #16 on: June 20, 2013, 03:55:49 pm »
No, it is Ansi.
After conversion it does not contain umlauts, but contains correct signs which replace ulmauts (ü -> u, ö -> o).
Lazarus does not make such replacement, it adds questions "?". Delphi makes such replacement.
How does it do this? I do not know. Maybe it calls some WinAPI function internally, I just do the assignment WideString to AnsiString.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1947
Re: WideString to AnsiString conversion
« Reply #17 on: June 20, 2013, 04:27:43 pm »
Sounds strange, and it's even wrong.

The correct replacements for german umlauts would be

ä -> ae
ü -> ue
ö -> oe
ß -> ss

jarto

  • Full Member
  • ***
  • Posts: 106
Re: WideString to AnsiString conversion
« Reply #18 on: June 20, 2013, 05:00:47 pm »
If you need Lazarus to convert those like your Delphi program is doing, do test all possible characters on Delphi, save the result and write your own function, that takes care of those characters, where Lazarus would convert differently.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12950
  • FPC developer.
Re: WideString to AnsiString conversion
« Reply #19 on: June 21, 2013, 01:29:44 pm »
The Windows unicode conversion routines have options that allow to find nearest character if a character can't be matched

Globally doing nearest like Delphi does, is somewhat bad though, since that would mean it also happens for urls and filenames which could cause security problems

 

TinyPortal © 2005-2018