2

I have a Classic ASP application running on a workstation with a Danish version of Windows 7 with IIS 7.5.

The problem: When the application writes a boolean as a string, it will write "True" or "False" on an English server. However, on my Danish installation, it will write out "Sand" and "Falsk".

The desired solution: What I need is to know which specific setting on my workstation/iis/configuration determines which language it writes out a boolean value to make sure it will always write out booleans in English.

I have tried the following already:

  • Set the LCID to 2057 (en_GB) for the ASP configuration of IIS.
  • Changed settings in Control Panel to English
    • Regional settings
    • Number and currency formatting
    • Language for non-Unicode programs
  • Changed the culture settings for ASP.NET in IIS
  • Restarted the workstation.

The following are not possible resolutions, so please don't suggest those:

  • Changing any code in the application.
  • Re-installing my workstation with an English version of Windows 7.
  • Changing the language of my Windows 7 installation (not possible because I am not using Ultimate and do not wish to upgrade)

Any suggestions will be appreciated. Thanks.

2
  • I'm unsure about what to do with this question. I got good suggestions, but not the answer. Am I supposed to most useful answer anyway? May 31 '11 at 5:10
  • "choose the" fell out of my sentence above. Am I supposed to choose the most useful answer anyway? May 31 '11 at 5:56
1

I don't know that the old OLEAUT regional settings hack applies, but I think it's worth a try - see what you get.

http://support.microsoft.com/kb/271587

SetVarConversionLocale should be set to 2, and the default regional settings set to US English.

If that doesn't work, and you can't change code in your application, run a virtual machine with a US English OS. You didn't specifically exclude that :)

3
  • Microsoft state that the problem is only for Windows 2000 and that it was corrected in SP2 for Windows 2000, so I don't think that particular problem snugg back into Windows 7. The virtual machine idea is actually not all bad :) May 30 '11 at 3:22
  • The binary that includes support for the registry setting was included in Windows 2000 SP2. (that's the "fix" they're talking about, they're not saying "this problem goes away") I assume support for the registry setting has been carried forwards; as I said, it's worth a try.
    – TristanK
    May 30 '11 at 8:21
  • Ahh okay, that makes sense. Unfortunately adding those registry keys didn't make any difference. I tried all of them and tried setting them to both 1 and 2 without any different result. I ran an iisreset in between. May 31 '11 at 5:55
0

When you change regional settings in the control panel, you are doing this for your user profile; but IIS worker process usually run in other user contexts, depending on the configuration of the application pool(s). You should try changing the regional settings for those account(s).

1
  • I checked which application pool the website is using. I changed that application pool to identify itself as my own user account. I also tried with Network Service and "ApplicationPoolIdentity". It didn't work.Thanks for the suggestion, though- May 30 '11 at 3:14
0

NOTE: I have also posted this solution to : https://stackoverflow.com/questions/15760035/boolean-values-in-local-language/44321629#44321629

Hi,

I was "caught" too with this "issue". Indeed, this is not an issue :

THE PROBLEM (EXAMPLE)

I had the same problem when using a boolean data in a SQL Statement. On my French server, my SQL statement was the following :

<%
'Set my boolean value
Dim myBoolean
myBoolean = True

'Set my SQL Statement
Dim MySQLStatement
MySQLStatement = "SELECT * FROM MyTable WHERE MyBooleanField = " & myBoolean
'=> Here, as MySQLStatement is a STRING, the boolean data was "converted/rendered" as a localized string. So that leads to this output :
'=> SELECT * FROM MyTable WHERE MyBooleanField = Vrai
'Obviously, that SQL Statement is incorrect, because the SQL Engine does NOT understand what is the "Vrai" word - It should be "True" instead.
%>

THE EXPLANATIONS :

  • It does not matter which regional settings are set on your Windows System : Nothing happens to the underlying data. A boolean data type is STILL a BOOLEAN, in English, or French, or German, Russian, Thai, ..or any language you want.
  • The fact is that the data is simply being RENDERED as a localized STRING (like dates).

THE SOLUTION

After a lot of reading over forums threads, the solution is not to change regional settings on the Windows system, nor changing Registry keys, nor changing Session.LCID, ... The absolute and code-only solution is to convert the Boolean value (True|False) to an Integer (0|1). Then, this Integer will be safely usable in a string, and will remain (0|1).

Here is the safe way to use/convert/render a Boolean value in a non-localized form : Use an Integer value.

<%
'Set my boolean value
Dim myBoolean
myBoolean = True

'Set my SQL Statement
Dim MySQLStatement
MySQLStatement = "SELECT * FROM MyTable WHERE MyBooleanField = " & BoolToInt(myBoolean)
'=> Here, as MySQLStatement is a STRING, and as the boolean data was previously "converted/rendered" as an integer, we got this correct SQL Statement :
'=> SELECT * FROM MyTable WHERE MyBooleanField = 1
'This SQL Statement is correct, as the SQL Engine DOES understand that 1 is a boolean.

'This Function Returns an INTEGER value based on a BOOLEAN value
Function BoolToInt(v)
    'INPUT:
    'v      Boolean value    

    'OUTPUT:
    'Integer (0|1)    

    Dim b_OUT
    b_OUT = v    

    'If the Input value is a "True" boolean value (in any language)
    if (b_OUT = True) then
        BoolToInt = cint(1)
    'If the Input value is a "False" boolean value (in any language)
    elseif (b_OUT = False) then
        BoolToInt = cint(0)
    end if
End Function 'BoolToInt
%>

I really hope it save your day !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.