Register

printf - and version 0.2.1 released

Jens
4 days, 2 hours ago
How do you convert a float to a string?

Ah well, let's deal with that later and just do printf("%f") to buffer!

As the Linux build of BEdit is now officially released, I had a small issue. Localization. Well, you might find this strange as BEdit is only available in English. Why does locale matter in any way or form?

If your Windows is in a non-English language, you know that a lot of applications fail to get the basic locale code correct. For example the MessageBox API-call will display the buttons in whatever language the OS is running in, causing some funny popups. (This is why I always use the MessageBoxEx call to explicitly set English as language.)

On Linux, and with X11, it's even worse. To support dead-keys for non-English keyboards (such as the ones I'm using), I need to set the input method to the user's locale. But that's not enough, I also need to set the C standard library locale to the user's locale. Fine, I set it, all works fine. I can write silly characters like ~ and ` without issues. So how does this relate to converting a float to a decimal representation?

Well, the decimal dot is not the same on all languages! I noticed that the Linux build didn't show the decimal as a dot, but rather as a comma - as my current locale would dictate. This is a bug I've even encountered on GDB where it used scanf to read my code to set a float, but interpreted it as a comma operator.

Thankfully BEdit uses printf very little (except the command line version that doesn't set the locale), so I decided to just replace all instances with my own conversion function.

And with this issue fixed, along with some other issues and new features, BEdit version 0.2.1 is released - including the very first Linux build. I've never distributed anything on Linux but I don't expect too many issues (famous last words).

As always, free command line versions are available for download here at handmade network, and also at itch io.
Log in to comment