You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "Sergej Koščejev (JIRA)" <ji...@apache.org> on 2011/03/22 13:01:06 UTC

[Lucene.Net] [jira] [Commented] (LUCENENET-85) SupportClass.Parse and System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator

    [ https://issues.apache.org/jira/browse/LUCENENET-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13009622#comment-13009622 ] 

Sergej Koščejev commented on LUCENENET-85:
------------------------------------------

The way this issue was fixed is absolutely atrocious (not to mention that it doesn't take into account numbers with thousands separators, such as "12 399,00").

The correct fix would be to use CultureInfo.InvariantCulture when formatting or parsing the numbers:

{code}
return System.Single.Parse(s, CultureInfo.InvariantCulture);
{code}

> SupportClass.Parse and System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: LUCENENET-85
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-85
>             Project: Lucene.Net
>          Issue Type: Bug
>            Reporter: Digy
>            Assignee: George Aroush
>            Priority: Minor
>         Attachments: SupportClass.patch
>
>
> Again System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator problem
>        public static System.Single Parse(System.String s)
>         {
>             try
>             {
>                 if (s.EndsWith("f") || s.EndsWith("F"))
>                     return System.Single.Parse(s.Substring(0, s.Length - 1).Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
>                 else
>                     return System.Single.Parse(s.Replace(".", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator));
>             }
>             catch(System.FormatException fex)
>             {
>                 throw fex;					
>             }
>         }

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira