Git Product home page Git Product logo

Comments (18)

chrjen avatar chrjen commented on May 31, 2024

This seems related, might want to read it. I tried running this code here.

NumberFormat.getInstance(Locale.GERMANY).parse("-5");
NumberFormat.getInstance(Locale.CHINESE).parse("-5");
NumberFormat.getInstance(new Locale("en", "GB")).parse("-5");
NumberFormat.getInstance(new Locale("no", "NO")).parse("-5");

Crashed on the fourth line Unparseable number: "-5". (It's the default local set by my computer)

Also it got closed as "Not an Issue" so it's apparently not a bug and is intended behaviour.

from imgui.

chrjen avatar chrjen commented on May 31, 2024

Yeah I just tried running my program on a JVM using a different default local and it doesn't crash anymore. So it only crashes depending on what region of the world you are from, lol.

If you can't reproduce the bug, try running the JVM with the arguments -Duser.country=NO -Duser.language=no. I'm also using Java 9 which might be relevant.

from imgui.

elect86 avatar elect86 commented on May 31, 2024

-Duser.country=NO -Duser.language=no did actually help to reproduce the error, coz I was having no excepetion with negative ns float dragging field.

Uhm, that's tricky to resolve. Shall we maybe detect and react according to the current locale?

Any tips?

Which was your original locale that provoked the crash?

from imgui.

chrjen avatar chrjen commented on May 31, 2024

My original locale is Norwegian no_NO.

I can really give any tips though as I have no idea what roundScalarWithFormat does or why the parse is necessary. Rounding by converting to string, then back again seems really strange to me (at least that's what I think it is doing).

from imgui.

elect86 avatar elect86 commented on May 31, 2024

In a comment, Omar wrote Round to user desired precision based on format string

I'll think about it

In the meanwhile... why the hell does it crash with negative values using Norwegian locale...? lol

Anyway, I just pushed a workaround, DecimalFormat will always use as locale style.locale (which is now a var and default US)

from imgui.

chrjen avatar chrjen commented on May 31, 2024

Don't think I understand Omar's thinking then. I don't see why the way a number is represented has to be tightly coupled with the actual value. If I wanted a slider with steps of 0.001 yet is formatted to only display a single decimal place of precision it should be my choice.

Anyway I got around to trying out the most recent commit (3620dfd) with the workaround and guess what, still broken, lol. The RGB sliders under (Widgets > Basics) causes the same exception to happen when the number of digits go below three due to the extra padding in front, Unparseable number: " 67", Unparseable number: " 4".

Would be nice to have locale not tied to US only. If the UI is in another language for example it would be nice having e.g. commas instead of a dot as a decimal separator if you set the locale that way.

from imgui.

elect86 avatar elect86 commented on May 31, 2024

I have no idea neither, but I'd guess he has his reasons, I need to check if this makes sense on jvm as well

Anyway, lol, man, what's wrong with norwegian format.. 😁

Pull again, dear. This time I also trim the begin of the string

As I said, default it us, but you can change it. It's style::locale

from imgui.

chrjen avatar chrjen commented on May 31, 2024

Ah, thank you. Though of course currently changing locale breaks the library..

I don't know why Norwegian is suppose to use a different minus sign. Also I just noticed I didn't seem to actually post the link in my previous comment that I intended for you to read -_-. Anyway this is what I found, link. In the reply it also links to a page on unicode that list which locales have different minus signs. So Norwegian is there (nb/nn) though it's not the only one using that special minus sign, but also Finnish, Swedish, Italian, etc.

from imgui.

elect86 avatar elect86 commented on May 31, 2024

Though of course currently changing local breaks the library..

What do you mean?

Uh, that link revealed to be actually quite important (I myself am italian...)

So, if we solve all the troubles you are having, I guess there is also a good chance we'll solve them also for all the other locales..

from imgui.

chrjen avatar chrjen commented on May 31, 2024

What do you mean?

Sorry, locale*.

Change the locale in imgui.style to e.g. Norwegian causes the same issues again. I mean your fix was to set the locale to US so naturally setting it to e.g. Norwegian again will make the unparseable number exception happen again.

from imgui.

elect86 avatar elect86 commented on May 31, 2024

I dont get any more exceptions..

I'm parsing now strings with DecimalFormat, it looks working flawless also for Norwegian locale

Give it a try

from imgui.

chrjen avatar chrjen commented on May 31, 2024

Tried commit fd68422 and it still throws the same ParseException as usual.

Just looking at the commit though I see nothing that has really changed except the default locale for everyone is now Norwegian instead of US.

from imgui.

elect86 avatar elect86 commented on May 31, 2024

Shit, that was unwanted :p

Anyway, I dont get why I dont get anymore the exception..

I tried passing -Duser.country=NO -Duser.language=no to JVM args..

However, I can still reproduce with

val dec = DecimalFormat().apply {
    decimalFormatSymbols = DecimalFormatSymbols(Locale("no", "NO"))
}
dec.parse("-5")

So, let's face the problem from another point of view, let's substitute the old minus with the new out

Give me good news, man ^^

from imgui.

chrjen avatar chrjen commented on May 31, 2024

Sure thing! Good news it now works if you set imgui locale to Norwegian!

Bad news? Every other locale now breaks with the same exception due to the new minus sign, including the default US locale.

from imgui.

elect86 avatar elect86 commented on May 31, 2024

Ok, then let's switch it only given on the style.locale

Anyway, I'm going crazy.

You can easily do it and test on your machine, since you can reproduce it easily.

Do you mind working on it directly? :)

Ps: tried to send you an invite, but apparently there is no result for @chrjen

You’ll only be able to find a GitHub user by their email address if they’ve chosen to list it publicly. Otherwise, use their username instead.

from imgui.

Sylvyrfysh avatar Sylvyrfysh commented on May 31, 2024

from imgui.

chrjen avatar chrjen commented on May 31, 2024

Well I can always try to help. Don't know why the username doesn't work. Also don't really know Kotlin, but a solution in Java shouldn't be very hard to translate into Kontlin, right?

from imgui.

elect86 avatar elect86 commented on May 31, 2024

If needed, chrjen could join lwjgl slack and message you there

Also, as he prefers

Well I can always try to help. Don't know why the username doesn't work.

Try to send me your email, here or on elect86 gmail

Also don't really know Kotlin, but a solution in Java shouldn't be very hard to translate into Kontlin, right?

Right and then you'll love it and you are gonna switch everything to Kotlin :)

from imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.