WPF TextBox - German letter ß automatically replaced with ü - c#

We'd added German localization to our WPF Application and later we've got a feedback from one of our German users. He told us that he was unable to input German letter "ß" - it was automatically replaced with letter "ü".
Looking forward to hear some answers or suggestions.
Issue example screenshot:

Finally I've found a problem. Actually our application use comparison and mapping of System.Windows.Input.Key and native ScanCodeShort to fix HotKeys functionality due to different cultures. As a result - German symbol 'ß' is detected as 'OEM4' key and as a ScanCodeShort it's equal to 'OemOpenBrackets'. That's why symbol 'ü' is inputted instead of 'ß'. Now I'm trying to find a solution for this problem, but it seems that's another story.

Related

Preventing Cyrillic/Greek/Chinese in a string - C# 4.0

We have a system (using ASP.NET C# 4.0) that supports Greek, Cyrillic, Chinese characters. But a third party system doesn't seem to work correctly. To avoid issues when entering data for this third party system, I want to limit the text fields to accept only English or accented characters, but return a validation error for other characters.
How can I accomplish this? It seems I can use a regex along the lines of \p{Latin}, but C# doesn't seem to support this from my experience, as I get an Unknown property 'Latin' error.
In .NET, the Unicode block properties need to be written with Is...:
[\p{IsGreek}\p{IsCyrillic}...]
A pattern like this would detect all offending characters in your case. If you just want to exclude everything but Latin, you could do something like:
[^\p{IsBasicLatin}\p{IsLatin-1Supplement}\p{IsLatinExtended-A}\p{IsLatinExtended-B}]
This covers all code points up to U+024F.
For a list of supported block names, see MSDN.

C# program stops working after the language setting in control panel is changed (say, from English to German)

I have a software developed in C#, which is a pure sentefic application. Howver the German users found this software stopped working from time to time, when it is installed on German computers. The temporary solution is to change the Language setting in the control panel, and it works fine after we change the language setting from German to English. This is just a kind of engineering sofware, and the software have nothing relalted to the German or English language. Also, as suggested from other posts in msdn, I have checked the "InitializeComponent()" in the source does several times. There are not strange codes in the "InitializeComponent()" function.
When you change locale, you change the meaning of ',' (comma) and '.' (full-stop) when used in numbers. Could it be that you are trying to parse text containing these characters into numbers?
Does your program attempt to initialize numeric fields with formatted numbers, perhaps?
You need to make sure that your code is sensitive to the user's culture when parsing and formatting text. You also need to make sure you use a consistent culture (e.g. the InvariantCulture) when reading data stored to file or sent over a network.
If you are using .NET Framework 4.5, you might be interested to read about the CultureInfo.DefaultThreadCurrentCulture Property.
In the .NET Framework 4 and previous versions, by default, the culture
of all threads is set to the Windows system culture. For applications
whose current culture differs from the default system culture, this
behavior is often undesirable.
The examples and their explanations on the page could be quite helpful for your issue.
Also, as a side note, try{...}catch{...} blocks are always welcome.

What culture code should I use for Pinyin?

My Question
If you want to display Pinyin for Chinese-speaking users, in what "resource file" would you store the Pinyin translation?
Since Pinyin is NOT a "language" per se, but a Latin representation of Chinese characters, it does NOT have a culture code in .NET.
My guess is that we probably need to use the applicable "zh-" (Chinese) cultures and simply place the latin character Pinyin translation inside those resource files.
I apologize in advance if this is a stupid question, but all the different culture stuff is scrambling my brain!!
Background
We're finally getting around to Internationalization of our Web sites. We're handling most of the "Western" cultures okay now (Latin alphabet: "es", "fr", "de") and the different date/number formats. However, the ideogram-based writing systems like Chinese are a challenge due to various legacy systems not handling Unicode. As a short-term workaround, our business area decided to use Pinyin for Chinese speaking users.
So... the business area asked me to "just add a Pinyin resource file" to the site.
The Microsoft culture code is in the format of :
"language-country"
So, take Chinese for example. The code for Chinese is "zh". However, there are many countries and regions that use Chinese, so we append a country code to the language code. "zh-cn" stands for Chinese-Mainland China. Similarly, "zh-tw" represents Chinese for Taiwan.
.Net uses the concept of resource fallback, where resource lookups begins at the level specified and as long as the resource is not found, a less specific resource will be looked at until we get to the default resource. So ideally, the "zh-cn" resource file should contain only resources that are specific to Mainland China. All resources that are common to all Chinese speaking countries should reside in the "zh" resource.
So getting to your question, I believe Pinyin is primarily used in mainland China, and since you are using it as a Chinese translation substitute, I would place the Pinyin translations inside the "zh-cn" resource file.

How do i let the user input text in German / French for a website

Is there a way that I can let the end user type text in German / French in a text box for a c# asp.net website. Is there any available solution for the same,
Thank You
You really need to read this:
http://www.joelonsoftware.com/articles/Unicode.html
Are you talking about transliterating from German/French into English? If so, that doesn't make much sense. Transliteration is used to convert one system of text/writing into another, like Greek to English or German to Chinese. With French, German, and English, there is no need to transliterate because they all use the same alphabet/writing system.
Was your question more about how to add a transliteration feature a la Google and you just used French and German as an example?

How do I validate for language? ASP.NET

In a textbox in the application, I need to validate to ensure that a user enters only English language text. I know some languages such as Spanish share English's alphabets. How do I validate text to make sure it's:
Only in English language
Supports only languages that use the English character set (Spanish etc)
Thanks
EDIT: Sorry for not being clear enough. This app is on production and when I check the SQL database where the text is stored, there are a lot of rows with "??? ?????". On further investigation, it appears that this is caused when a non english language text is saved to a database. As an example, go to google news, select google Korea from the dropdown, copy some Korean text and save it to a SQL server database
Anyone?
By "English character set", I guess you are referring to the ASCII character set.
You can iterate through each character and see whether it lies in the ASCII range.
You can try to check against an English dictionary (e.g. OpenOffice has a dictionary which you may use for free, not sure about that though) if most of the used words are recognized by this dictionary.
You could also do some kind of text analysis and check the occurance of each character or short sequence like 'th' etc. Each language has specific character occurances and this could help you determining in what language the text is written.
I would not prohibit certain characters because at least in names special characters occur quite often.
I hope you got an idea of some possibilities.
Best Regards, Oliver Hanappi
If this is for a moderately small amount of text, you could try finding an English dictionary web service and try to look up the words. If lookup fails, you most likely either have a typo or something from another language. I haven't found one that accepts large blocks of text, but there is a web service that operates off of the dict.org database:
DictService
One way is to use a English Language Dictionary / Spell Checker , if is valid English / Spanish Word
a very good sample is this
NetSpell Sample - Spell Checker for .NET
It is as simple as follows
NetSpell.SpellChecker.Spelling SpellChecker =
new NetSpell.SpellChecker.Spelling SpellChecker()
SpellChecker.Text = MyTextBox.Text;
SpellChecker.SpellCheck();
NetSpell Home Page: http://www.loresoft.com/NetSpell

Categories