Recent

Author Topic: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?  (Read 4617 times)

Akira1364

  • Hero Member
  • *****
  • Posts: 563
Or, more importantly, what do they both ACTUALLY do? I have never seen a good explanation for this. Some people seem to describe "Use AnsiStrings" as though it were only there for legacy purposes, and others say that if you turn it off, ALL your strings will be ShortStrings by default. That being said, I have compiled applications with it turned both on and off many times, and never noticed any tangible difference either way, or received any different warnings either way. Checking and unchecking "Set UTF8 In RTL" also seems to do absolutely nothing. What am I missing? I am using trunk FPC, by the way.

malcome

  • Jr. Member
  • **
  • Posts: 81
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #1 on: October 18, 2015, 03:04:41 am »
こんにちは。名前からお見受けして日本の方ですか?
日本語で書いても許されるんでしょうかねここは?試しに書いてみます。
Use Ansistrings はかなり古いDelphi(v1?)との互換性のためなのでオフにすることはないと思います。
Set UTF8 In RTL" はFPC3.0以上で使えます。ONにすると例えばLoadFromFileメソッドとかでUTF8のパスが通るようになります(内部で自動的にW系APIが使われる)。OFFの場合はFPC2.6以下と同様にW系を使用するUTF8ルーチンを使わなければA型が使われることになりますので、SHIFTJISの範囲の文字しか使えません。

Akira1364

  • Hero Member
  • *****
  • Posts: 563
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #2 on: October 18, 2015, 03:45:20 am »
UM! Speaking of character encoding issues...  :o

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #3 on: October 18, 2015, 05:09:18 am »
malcome's message translated by google
Quote
Hello. Are You a Japan was seen from your name?
It Would do even allowed to write in Japanese here? I'll try to write to try.
Use Ansistrings think not be turned off because for compatibility with quite old Delphi (v1?).
Set UTF8 In RTL "is the case of You can also use and to .ON for example, will pass through the UTF8 path in the Toka LoadFromFile method (W-based API is used automatically internally) .OFF in FPC3.0 more FPC2 .6 below and it will be in the same way that you have to use the UTF8 routines that use the W-based a-type is used, you can not use only characters in the range of SHIFTJIS.

...and yes, the name
« Last Edit: October 18, 2015, 05:19:42 am by skalogryz »

Akira1364

  • Hero Member
  • *****
  • Posts: 563
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #4 on: October 18, 2015, 05:45:06 am »
I sort of figured that was the case. I am of Japanese ancestry but don't speak the language. So I'm not "a Japan", as Google aptly put it. Also, I'm still no further along in understanding the subjects of my original question.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #5 on: October 18, 2015, 06:02:50 am »
"Set UTF8 in RTL" is a lazarus specific feature to force rtl to behave as if, it's using UTF8 encoding. (on Windows some sort of ansi or multi-byte encoding would be used, but not utf8). Yet again, it's not FPC feature, it's Lazarus workaround to make RTL act more friendly towards LCL.

"Use AnsiString" is FPC compiler feature. More or less introduced awhile ago for compatibility with delphi. It actually means type "string" is "AnsiString" nothing more. You want to keep this feature off if you're porting some old (TP/BP) or gnu, iso or macpascal code.

So all in all, these two features are unrelated.

Akira1364

  • Hero Member
  • *****
  • Posts: 563
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #6 on: October 19, 2015, 12:24:38 am »
So the people who said turning off "Use AnsiStrings" means all strings default to Short were correct? Meaning that basically, I should leave it turned on forever, since I'm never going to be porting old TP code?

malcome

  • Jr. Member
  • **
  • Posts: 81
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #7 on: October 19, 2015, 02:37:03 am »
I'm sorry it was my misunderstanding.
...And Google translater is terrible.

Quote
I should leave it turned on forever, since I'm never going to be porting old TP code?
YES. Turned on forever, unless you return to 16bit PC.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8819
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #8 on: October 19, 2015, 02:41:19 am »
YES. Turned on forever, unless you return to 16bit PC.
Or you know you'll need shortstrings only. There are times when shortstrings are preferred over ansistrings, but that depends on the app of course. Choose wisely.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: How do "Set UTF8 in RTL" and "Use AnsiStrings" relate to each other?
« Reply #9 on: October 19, 2015, 04:42:38 am »
...And Google translater is terrible.
It is... but at least it "sketches" the general idea of the message :)

 

TinyPortal © 2005-2018