Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-125766

Number.fromLocaleString() doesn't handle multiple spaces

    XMLWordPrintable

Details

    • Windows
    • 8
    • Foundation PM Staging

    Description

      Got this on Qt.locale("pl_PL")

      For large numbers in standard notation, function Number.FromLocaleString() returns Invalid Format. The core issue seems to be that it doesn't handle well multiple separate spaces within one number
      To reproduce:

      Number.fromLocaleString(Qt.locale(),"9 999 998,20");    //exception Invalid Format
      Number.fromLocaleString(Qt.locale(),"9999 998,20");    //OK
      

      For large numbers, the conversion also doesn't work both ways.

      Minimal code to reproduce:

      import QtQuick 2.15
      import QtTest 1.0
      
      TestCase {
          name: "NumberToLocaleString"
      
          function test_case1() {
              Number.fromLocaleString(Qt.locale("pl_PL"),"9 999 998,20");    //exception Invalid Format
              verify(false);
          }
          function test_case2() {
              Number.fromLocaleString(Qt.locale("pl_PL"),"9999 998,20");    //OK
              verify(true);
          }
          function test_case3() {
              var num = Number(9999998.20).toLocaleString(Qt.locale("pl_PL"));
              console.log(num)
              Number.fromLocaleString(Qt.locale(),num);    //exception Invalid Format
              verify(true);
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Eddy Edward Welbourne
            kdluzynski Krzysztof Dłużyński
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes