4
Vote

Localzation issue on convertion to string

description

Converting point values on none english systems cause compile error on inline shader declaration because on different decimal point (German: ',' instead of '.').
Shaders2.cs:1696: codeFor ...
Please add on ToString the correct localization like
X.ToString(CultureInfo.CurrentCulture.Numberformat)

file attachments

comments

KirillOsenkov wrote May 14, 2009 at 9:41 PM

Current culture won't work because C# expects literals in invariant culture.
Use 3.14.ToString(CultureInfo.InvariantCulture);

wrote Jul 21, 2009 at 12:17 PM

marten_range wrote Jul 21, 2009 at 12:31 PM

This issue isn't low impact on any system using a decimal point other than '.'. It renders the shader part of bling unusable. I like the shader part alot, I want to use it.

Anyway, I created a small patch that seems to work for me. I don't know bling at all so I might missed some cases.

Current (as of 35476)
Shaders.cs:
    Func<int, string> EToString = (idx) => {
      var e = arity.Access(constant.Value, idx);
      if (arity.TypeOfK == typeof(bool)) return ((bool)e) ? "1" : "0";
      else return e.ToString();
    };
Patched:
    Func<int, string> EToString = (idx) => {
      var e = arity.Access(constant.Value, idx);
      if (arity.TypeOfK == typeof(bool)) return ((bool)e) ? "1" : "0";
      if (arity.TypeOfK == typeof(double)) return ((double)e).ToString(CultureInfo.InvariantCulture);
      else return e.ToString();
    };
Just added a check for double.

I hope this can fixed as it would suck if someone uses bling to create cool apps and norweigans, swedes, danes and germans can't use them.

I attached the patched file.

wrote Jul 21, 2009 at 12:31 PM

wrote Feb 14, 2013 at 1:24 AM