Writeln(AnsiSameText(a, b));
-// what if we would get rid of the 2 parameter overload and use the 3 param overload but with
- TLocaleOptions = (loInvariantLocale, loUserLocale, loUseGlobalBehavior);
+// what if we would introduce a global switch to control the behavior to
+// keep the old behavior or have those methods handle unicode automatically
DoLegacyStringStuff: Boolean = True;
-// just hacking this up without copying code from SysUtils
-function SameText(const S1, S2: string; LocaleOptions: TLocaleOptions = loUseGlobalBehavior): Boolean;
+// just hacking this up and naming it differently for this demo to not collide with the existing functions
+function SameTextNew(const S1, S2: string): Boolean;
- if LocaleOptions = loUseGlobalBehavior then
- if DoLegacyStringStuff then
- LocaleOptions := loInvariantLocale
- LocaleOptions := loUserLocale;
- Result := System.SysUtils.SameText(S1, S2, System.SysUtils.TLocaleOptions(LocaleOptions));
+ if DoLegacyStringStuff then
+ Result := SameText(S1, S2)
+ Result := AnsiSameText(S1, S2);
// without changing the DoLegacyStringStuff variable we have the same as before
Writeln('after change without touching global variable:');
- Writeln(SameText(a, b));
+ Writeln(SameTextNew(a, b)); // this would be SameText in real code
Writeln(SameText(a, b, loUserLocale));
Writeln(AnsiSameText(a, b));
DoLegacyStringStuff := False;
Writeln('changing global variable:');
- Writeln(SameText(a, b));
+ Writeln(SameTextNew(a, b)); // this would be SameText in real code
Writeln(SameText(a, b, loUserLocale));
Writeln(AnsiSameText(a, b));