Solved

is there a setlocale in .net?

Posted on 2004-10-20
18
982 Views
Last Modified: 2013-11-25
im used to do this on coldfusion.
i could set the locale settings for the application.

im having problems with my application if i set the locale setting of windows to a different language
(control panel\Regional Settings\Regional Option)

different kinds errors shows up.
i figured if i could just set the application to use US only locale and not to use windows locale
 then my application is good to go.. i guess..

ideas?

if i set Regional option to Sami,southern(norway). my application wont run.
If i set to chinese(hongkong), lots of unexpected behaviors are happening.
Im not even using any date,currencies,time functions.

0
Comment
Question by:Jerry_Pang
  • 10
  • 5
  • 2
  • +1
18 Comments
 
LVL 28

Expert Comment

by:mmarinov
ID: 12366824
Hi Jerry_Pang,

you have to set the current thread to use new CultureInfo("en-US")

Regards!
B..M
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12366894
help. could you show me some examples how?
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 350 total points
ID: 12366991
Jerry_Pang,

do you use windows or web application ?
if you use windows application, before start a new thread and on start of the application write

System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

B..M
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12367390
i found the main cause.

its on the web application not on my windows application code.

=). how to set on web application?
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12367666
Jerry_Pang,

the you have to set the culture info as i posted before in every page

B..M
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12377106
yes i have. no probs with my application.

it was somewhere within the html>activex>html.
its not on any of my code.

i think the problem was html encoding or something.

will try to use html charset.
is there a processing directive?

anyways, i have found the root cause already, will try different approaches to fix the problem.
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12377454
hm..

control panel\regional and language settings\regional option
Set to Chinese Hongkong (install east asian language)

if i submit ñ or other chinese characters, the next page wont display.
we submit these characters to activx for processing.

this works if Language is set to EN-US but not if chinese or other characters.

any ideas?

the question is already answered. will increase points for set locale in web.
another points for any ideas, suggestions what to do next.

thanx
0
 
LVL 28

Assisted Solution

by:mmarinov
mmarinov earned 350 total points
ID: 12378143
i'm not sure how these characters are send through or to the activex so may be the process stops because they means something special
can you try to output some information when the activex sees characters like this

also the current culture depends on the first language set in the (example for IE ) Tools->Internet Options->Languages->Languages Preference

also, so may be the activex gets this language and try to work based on it

B..M
0
 
LVL 22

Assisted Solution

by:CJ_S
CJ_S earned 100 total points
ID: 12379136
Copy pasted from my answer the other day

---------

I suggest you to look a the CultureInfo class provided by the .Net framework whcih is used by the HttpContext.CurrentCulture and CurrentUICulture. By setting the correct culture you can change the way datetime objects are shown on the screen and how they are used within your system. The easiest way would be by setting the correct property in the web.config.

For example:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="nl-NL" uiCulture="nl-NL" />
 </system.web>
</configuration>

Look at the properties culture and uiCulture.

However, when you are talking with a database you might have to always work with american date format (mm-dd-yyyy).

CJ.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12396721
5
0
 
LVL 6

Assisted Solution

by:etmendz
etmendz earned 50 total points
ID: 12406969
It seems that the remaining issue is in your ActiveX.

Is it designed to support non-English characters/settings?
Did you create this ActiveX? What language?
What does the ActiveX do?
Does it process text? Dates? Numbers?
Does it connect to the database? What database?
Does it call stored procedures?
Does it execute dynamic queries?

Maybe if you can give more information about the ActiveX we can help you more...
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12407935
oop.s o thought i have close the question already..

anyways,

Did you create this ActiveX? What language?
i did not create this activex, i dont know.

What does the ActiveX do?
i have no idea, we just send some xml and the other IE page will show/display err.. sumthing.

Does it process text? Dates? Numbers?
hmmm.. i dont think so, we just send some xml data and let it process. it think it has something to do with double byte characters. it occurs with chinese/japanese/korean language i think.

Does it connect to the database? What database?
no it wont anymore. i handle the database connection, they think its my bug. i found the root cause, its on the web, somewhere on xml parsing i think.

Does it call stored procedures?
nope.

Does it execute dynamic queries?
nope..

it only parses the XMLdata.

sample xml that it wont accept is
<title>
Español - Wont accept ñ
Some chinese characters -wont display properly
</title>

i was thinking of converting it to &#u00?? but it wont accept & either.

0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12407950
>Does it process text? Dates? Numbers?
>hmmm.. i dont think so, we just send some xml data and let it process. it think it has something to do with double byte >characters. it occurs with chinese/japanese/korean language i think.

it works perfectly if the regional settings is english US
it wont work if the regional settings is set to Chinese (Hongkong)

if OS language is set to English, everything is OK. it will accept any unicode characters.
If OS language is set to Chinese, bugs everywhere.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12407984
because of no way escaping of this ( it is client maching properties ) i suggest you in your application what is the cultureinfo and if it is not en-US then redirect to an error page, that tells the user to change the browser language to en-US or he/she will can not be able to work with the site

B..M
0
 
LVL 6

Expert Comment

by:etmendz
ID: 12408089
Then maybe it is simply safe to conclude that the ActiveX does not support non-English characters and should be replaced with something else that can support non-English characters. Most ActiveX are independent on the HTML and browser settings though they tend to use the machine's settings.

Have fun.
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12417593
hello mmarinov.
the html is just a plane html page.
its not an aspx page.

my application
generates an XML ---> to be submited to HTML page ---> opens activex and recieves the Activex  ---> to a different browser

Somewhere i think their html to activex or from activex to a different browser is the problem.

We are doing a different test now. hopefully we could solve this problem.

im planning to convert al the unicode characters into &#u00??? equivalent. from the test it doesnt accept '&' either.

thanx anyways for all your help. i will be closing this question now.
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12417843
solve.

We created an activex test to accept xml, output the text if it is still ok.
after the activex process, output it again and test the result if its still ok.

I found the solution.
i converted the non ascii characters to &#unicode; equivalent and now its working ok..

now i will have to make some major changes in my application again to accept &#unicode; instead of the actual characters. thanx
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 12418423
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now