Apache OpenOffice (AOO) Bugzilla – Issue 70236
CDbl truncates values with locale setting passed by an environment variable
Last modified: 2017-05-20 11:00:59 UTC
This is the same bug reported on issue #21413, where it is asked to submit another issue if reproduced. When a locale which uses the comma as the decimal separator is passed by an environment variable, with a command line like: env LANG="it_IT@euro" ooffice a Basic Macro like this: MsgBox CStr(CDbl("1234,5678")) gives "1234" instead of "1234,5678". CDbl truncates the decimal part. This happens only under Linux, on Windows it works as expected. If the locale is set using Tools->Options->Language Settings->Languages it works also under Linux. The bugs happens only when the locale is set using the environment. I tested this only with Calc and Italian locale settings, but probably it happens also with other components and with other locales using the comma as the decimal separator.
Please replicate the issue with OpenOffice version 2.1. Thanks.
I'll do as soon as I have OOo 2.1 installed on my Linux server. I'm waiting for the Fedora Core official update.
Using 2.2RC3 on Suse 10.2 Depending on what I set Tools - Options - Language Settings - Languages - Localle Setting I see following behavior 1. Default (US English, "." as decimal separator) - I see "12345678" as output of "MsgBox CStr(CDbl("1234,5678"))" 2. Italian (Italy) ("," as decimal separator) - I get "1234,5678" as output of the macro. 3. Italian (Italy) ("," as decimal separator) - I get "55,359722222" as output of "MsgBox CStr(CDbl("1234.5678"))" (note dot as decimal separator). dindy, please specify how do I use enviroment variable to pass localle setting to OO macro. Thanks.
Hello Kpalagin, I'm probably missing your question. In the first message I reported: env LANG="it_IT@euro" ooffice Isn't this enough? BTW, I haven't tested yet with 2.1, sorry. Fedora Core 5 is still at 2.0.2 and unfortunately I'm quite busy so I have little time to download a newer version from some other source and test with it, but if it's really needed I'll try to find some spare time and do the tests. Thanks for your efforts. Bye,
Confirming with 2.2RC3 on Suse 10.2: 1. Starting OO with localle specified in command line produces "1234" as an output of MsgBox CStr(CDbl("1234,5678")) 2. Setting "Italy" in Tools->Options->Language Settings->Languages and running MsgBox CStr(CDbl("1234,5678")) produces "1234,5678".
Hi, tried it with FC and could not reproduce. Tried again with Suse 10.1 and can reproduce. Andreas please have a look at this one. QA framework has a machine there I can show you the problem. Frank
ab->er: As already described in #i21413, I have no idea what can be done in Basic to solve this problem. Basic can do nothing here but rely on the information provided by SvtSysLocale and under certain circumstances this information seems to be not correct. As you are the cvs owner of svtools/inc/syslocale.hxx I reassign this task to you.
Dindy, The LANG variable has a low precedence and may get overridden by the LC_ALL and LC_CTYPE (which itself may be overridden by LC_ALL again) variables. Check with the command 'locale' if these are set to a locale that has a different decimal separator. "Set" here means that the actual environment variable is set, the locale command in that case displays the value without quotes ("), as opposed to a quoted value that designates an inherited value from the actual locale selected. You may also check using the commands echo $LC_ALL respectively echo $LC_CTYPE where any output means it will override your LANG value. Eike
Hello Eike, I'm not sure I completely understand your request. BTW the locale command by itself gives the following output: [root@server ~]# locale LANG=en_US LC_CTYPE="en_US" LC_NUMERIC="en_US" LC_TIME="en_US" LC_COLLATE="en_US" LC_MONETARY="en_US" LC_MESSAGES="en_US" LC_PAPER="en_US" LC_NAME="en_US" LC_ADDRESS="en_US" LC_TELEPHONE="en_US" LC_MEASUREMENT="en_US" LC_IDENTIFICATION="en_US" LC_ALL= Instead the locale command with the same env variable as OOo gives the following output: [root@server ~]# env LANG="it_IT@euro" locale LANG=it_IT@euro LC_CTYPE="it_IT@euro" LC_NUMERIC="it_IT@euro" LC_TIME="it_IT@euro" LC_COLLATE="it_IT@euro" LC_MONETARY="it_IT@euro" LC_MESSAGES="it_IT@euro" LC_PAPER="it_IT@euro" LC_NAME="it_IT@euro" LC_ADDRESS="it_IT@euro" LC_TELEPHONE="it_IT@euro" LC_MEASUREMENT="it_IT@euro" LC_IDENTIFICATION="it_IT@euro" LC_ALL= This means that the env command actually completely changes the locale settings, as expected, isn't it? Let me know if you need further tests. Bye,
Hello again Eike, I tried also as the non root user which noraly run OOo. Same result. I also remember that, before opening this bug, I also tried by setting each single locale variable to the right value, both using the env command and by setting it in the shell rc, but nothing changed. [denis@server ~]$ locale LANG=en_US LC_CTYPE="en_US" LC_NUMERIC="en_US" LC_TIME="en_US" LC_COLLATE="en_US" LC_MONETARY="en_US" LC_MESSAGES="en_US" LC_PAPER="en_US" LC_NAME="en_US" LC_ADDRESS="en_US" LC_TELEPHONE="en_US" LC_MEASUREMENT="en_US" LC_IDENTIFICATION="en_US" LC_ALL= [denis@server ~]$ env LANG="it_IT@euro" locale LANG=it_IT@euro LC_CTYPE="it_IT@euro" LC_NUMERIC="it_IT@euro" LC_TIME="it_IT@euro" LC_COLLATE="it_IT@euro" LC_MONETARY="it_IT@euro" LC_MESSAGES="it_IT@euro" LC_PAPER="it_IT@euro" LC_NAME="it_IT@euro" LC_ADDRESS="it_IT@euro" LC_TELEPHONE="it_IT@euro" LC_MEASUREMENT="it_IT@euro" LC_IDENTIFICATION="it_IT@euro" LC_ALL= Bye,
Hi Dindy, > Instead the locale command with the same env variable as OOo gives the > following output: > > [root@server ~]# env LANG="it_IT@euro" locale > [... all it_IT@euro ...] > > This means that the env command actually completely changes the locale > settings, as expected, isn't it? Yes, looks good. However, I also get the behavior in OOo as desired. > Let me know if you need further tests. Just to make sure we dont miss anything : what is the value of Tools -> Options -> Language Settings -> Languages -> Locale setting? If using the env LANG="it_IT@euro" ooffice command, are you able to input numbers with the expected separators in the Calc spreadsheet application? Are they correctly recognized as numbers, or do they stay text? You can tell by 1. number is right aligned, text is left aligned, and 2. =SUM(cell) gives the value, and not 0. Thanks Eike
Hello Heike, I have to start oocal with the following command: env LANG="it_IT@euro" DISPLAY="pisolo:0" oocalc because the server has no monitor attached. The XServer is XFree86 under Cygwin/Win2000 Italian. BTW think it makes no difference. The "Tools -> Options -> Language Settings -> Languages -> Locale setting" menu path is in Italian. It becomes "Strumenti -> Opzioni -> Impostazioni lingua -> Lingue -> Schema locale". The value in the listbox is "Standard". All other values looks correct for the italian settings. I'll add an attachment with a screenshot of the form. The comma "," is properly accepted as a decimal separator within oocalc, numbers are recognized as numbers, and not text. The dot "." is instead recognized as a time separator. Everything looks correct. Bye,
Created attachment 44165 [details] Locale settings form screenshot
Hi Dindy, > Hello Heike, Don't try to change my gender ;-) > I have to start oocal with the following command: > > env LANG="it_IT@euro" DISPLAY="pisolo:0" oocalc > > because the server has no monitor attached. The XServer is XFree86 under > Cygwin/Win2000 Italian. BTW think it makes no difference. It shouldn't, if the machine where OOo runs on supports the locale. > The "Tools -> Options -> Language Settings -> Languages -> Locale setting" menu > path is in Italian. It becomes "Strumenti -> Opzioni -> Impostazioni lingua -> > Lingue -> Schema locale". The value in the listbox is "Standard". All other > values looks correct for the italian settings. I'll add an attachment with a > screenshot of the form. Everything fine there. > The comma "," is properly accepted as a decimal separator within oocalc, > numbers are recognized as numbers, and not text. The dot "." is instead > recognized as a time separator. Everything looks correct. Which in fact also means that the proper locale is used by OOo. Just that Basic doesn't get it. @ab: Andreas, how do you obtain the locale settings for CDbl? Please give me a pointer to the source code in Basic. @fst: Frank, what did you mean with > tried it with FC and could not reproduce. Tried again with Suse 10.1 and > can reproduce. Are you sure the Suse machine had an it_IT@euro locale installed? Did Calc use the proper locale settings? Thanks Eike
ab->er: ImpGetIntntlSep in basic/source/sbx/sbxscan.cxx
Andreas, I think I found the culprit. The ImpScan() function that is internally used to scan values from strings tries to be smart by removing group separators, changing the decimal separator to a dot and then call atof() on the string. That doesn't work, as on some systems functions like atof and strtof/strtod are localized. Please use ::rtl::math::stringToDouble() from rtl/math.hxx instead, which may as well replace the entire while-loop except the 'D' Basic specialty. Eike
Thanks, Eike STARTED
-> 3.x
cSng truncates the value too. It is for French, Russian locales too. Sub Main Separator = Left(Right(cStr(1.1), 2), 1) msgbox cDbl("123"+Separator+"1234") ' Shows "123". Should show 123,1234 for msgbox cSng("123"+Separator+"1234") 'French, Russian and similar locales where "," is a separator End Sub
Operating System is Linux. Spanish is affected too. This issue is confirmed for Linux: 3.0.1 for Russian and French 3.1.0 for Russian, French, Spanish OOO310m14 for Russian This issue does not appear on Windows with OOO310m11.
In the above examples the word "locale" means the System locale+OOo locale. For example, "French locale" means the system user interface is French and the OOo user interface is French and all OOo language settings are French. For Russian it means ALL is Russian. For Spanish, ALL is Spanish. If use USA system locale plus USA build of OOo, but in the language settings for OOo to choose Russian locale, then the separator is comma (","), but the issue does not apper and cDbl with cSng work correct, showing 123,1234. It means, you can't test this issue just by changing locale in OOo, you need to change ALL system locale variables, that is easily done on Linux by creating new users and installing language packs for OOo and the system.
To test this issue on Linux it is sufficient to change the system locale. This issue does not depend on OOo locale and even on the separator used by OOo. Just these system variables are important: LANG=ru_RU.UTF-8 LC_CTYPE="ru_RU.UTF-8" LC_NUMERIC="ru_RU.UTF-8" LC_TIME="ru_RU.UTF-8" LC_COLLATE="ru_RU.UTF-8" LC_MONETARY="ru_RU.UTF-8" LC_MESSAGES="ru_RU.UTF-8" LC_PAPER="ru_RU.UTF-8" LC_NAME="ru_RU.UTF-8" LC_ADDRESS="ru_RU.UTF-8" LC_TELEPHONE="ru_RU.UTF-8" LC_MEASUREMENT="ru_RU.UTF-8" LC_IDENTIFICATION="ru_RU.UTF-8" LC_ALL= LANG=es_ES.UTF-8 LC_CTYPE="es_ES.UTF-8" LC_NUMERIC="es_ES.UTF-8" LC_TIME="es_ES.UTF-8" LC_COLLATE="es_ES.UTF-8" LC_MONETARY="es_ES.UTF-8" LC_MESSAGES="es_ES.UTF-8" LC_PAPER="es_ES.UTF-8" LC_NAME="es_ES.UTF-8" LC_ADDRESS="es_ES.UTF-8" LC_TELEPHONE="es_ES.UTF-8" LC_MEASUREMENT="es_ES.UTF-8" LC_IDENTIFICATION="es_ES.UTF-8" LC_ALL= LANG=fr_FR.UTF-8 LC_CTYPE="fr_FR.UTF-8" LC_NUMERIC="fr_FR.UTF-8" LC_TIME="fr_FR.UTF-8" LC_COLLATE="fr_FR.UTF-8" LC_MONETARY="fr_FR.UTF-8" LC_MESSAGES="fr_FR.UTF-8" LC_PAPER="fr_FR.UTF-8" LC_NAME="fr_FR.UTF-8" LC_ADDRESS="fr_FR.UTF-8" LC_TELEPHONE="fr_FR.UTF-8" LC_MEASUREMENT="fr_FR.UTF-8" LC_IDENTIFICATION="fr_FR.UTF-8" LC_ALL= And other similar locales (Italian, etc) with internal comma separator (?)
Created attachment 63361 [details] example of not working cDbl and cSng on a French system with USA OOo
Same problem on ubuntu 9.10, DEV300m82, Czech locale,comma as the decimal separator. LANG=cs_CZ.UTF-8 LANGUAGE=cs_CZ.UTF-8 LC_CTYPE="cs_CZ.UTF-8" LC_NUMERIC="cs_CZ.UTF-8" LC_TIME="cs_CZ.UTF-8" LC_COLLATE="cs_CZ.UTF-8" LC_MONETARY="cs_CZ.UTF-8" LC_MESSAGES="cs_CZ.UTF-8" LC_PAPER="cs_CZ.UTF-8" LC_NAME="cs_CZ.UTF-8" LC_ADDRESS="cs_CZ.UTF-8" LC_TELEPHONE="cs_CZ.UTF-8" LC_MEASUREMENT="cs_CZ.UTF-8" LC_IDENTIFICATION="cs_CZ.UTF-8" LC_ALL=
I think keywords here can be removed?
Yes, no further locale info needed..
>------- Additional comments from ab Wed Apr 18 14:04:51 +0000 2007 ------- > >Thanks, Eike > >STARTED This issue is started for almost 4 years. Are there any difficulties? Maybe, you can reassign it to someone else?
This month it’s ten tears since this bug was first reported and I just want to confirm it is still present on: AOO 4.1.3 on Linux Mint 18 AOO 4.1.2 on Manjaro Linux 16.08 AOO 4.0.1 on Sparky Linux 4.2 cDbl and cSng not working when using USA AOO with LC_NUMERIC="sv_SE.UTF-8”. If it is changed into LC_NUMERIC="en_US.UTF-8" it is working.
Reset assigne to the default "issues@openoffice.apache.org".