This question has been asked long time ago on serverfault but no working awnser. I'm hoping somebody has encountered it and found a solution since then.
Example:
<%
Response.Write True
Response.Write "<hr>"
Response.Write "test:" & True
%>
Output:
True
--------------
test:Waar
As you can see, as soon as you combine the output, its turned into a local string ('Waar' is dutch for true). I need it to stay "True".
How can I change this? I dont mind putting some code at the beginning of the pages, but I cannot change all instances of True
in the entire code. So creating a function like below to return the correct string wont do.
Function PB(pVal)
If pVal Then
PB = "true"
Else
PB = "false"
End If
End Function
In computer science, a boolean or bool is a data type with two possible values: true or false. It is named after the English mathematician and logician George Boole, whose algebraic and logical systems are used in all modern digital computers.
Boolean values and operationsConstant true is 1 and constant false is 0. It is considered good practice, though, to write true and false in your program for boolean values rather than 1 and 0.
A variable of the primitive data type boolean can have two values: true and false (Boolean literals). or off. Boolean expressions use relational and logical operators. The result of a Boolean expression is either true or false.
Strange, I cannot get my IIS to output a boolean value in my local language no matter which locale is set.
Did you find this KB article already?
There is a description of a registry setting that could do the trick:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLEAUT
I don't want to mess with my production server, so I didn't try this yet.
FIRST ANSWER:
You could 'trick' VB to use your own functions. If you add these functions to the top of your page, VB will prefer these over the builtin ones, in this case CStr
and Trim
. Maybe this helps.
Function PB(pVal)
If pVal Then
PB = "true"
Else
PB = "false"
End If
End Function
Function CStr(pVal)
CStr = PB(pVal)
End Function
Function Trim(pVal)
Trim = PB(pVal)
End Function
Output:
True
--------------
test:true
--------------
test:true
--------------
test:true
I do something like this, but currently don't have a machine to test your case:
<%
Response.Write FormatDateTime(Now) & "<br />"
oldLocale = SetLocale(1026) 'Bulgarian
Response.Write FormatDateTime(Now) & "<br />"
SetLocale oldLocale
Response.Write FormatDateTime(Now) & "<br />"
%>
... from another SO question, it looks the above doesn't work.
What hapopens if you try these:
Response.Write "test:" & CStr(True)
or
Response.Write "test:" & Trim(True)
with or w/o SetLocale?
that is just like string concatenation works in vbscript.
from the vbscript language reference:
"Whenever an expression is not a string, it is converted to a String subtype. If both expressions are Null, result is also Null. However, if only one expression is Null, that expression is treated as a zero-length string ("") when concatenated with the other expression. Any expression that is Empty is also treated as a zero-length string."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With