Penguen
Penguen

Reputation: 17298

How can i convert my string with my common language to English?

I have some Excel data including an Excel column I created programatically in sql table my excel column on the other hand. One of the column's name's is mydetail. When I try to convert it to uppercase I get MYDETAİL. How do I use the ToUpper() method to obtain MYDETAIL not MYDETAİL?

Upvotes: 0

Views: 3099

Answers (3)

Filburt
Filburt

Reputation: 18092

You will need to call .ToUpper() with the desired CultureInfo. See MSDN with some examples on how to use .ToUpper(CultureInfo).


It is recommended to specify CultureInfo on all String manipulation methods like String.Format(), <primitive>.ToString() or for example Convert.Int32(object, CultureInfo).

FxCop does a good job in reminding you on issues with this in your code.

Upvotes: 0

Rox
Rox

Reputation: 2023

Try something like:

String result = source.ToUpper(CultureInfo.InvariantCulture);

From MSDN:

use the InvariantCulture to ensure that the behavior will be consistent regardless of the culture settings of the system

Upvotes: 1

ChrisF
ChrisF

Reputation: 137188

I'm guessing that you are Turkish, or at least using a Turkish computer.

In Turkish the "i" does convert to "İ" in upper case.

You need to use a different culture when doing the conversion by using String.ToUpper method that takes an CultureInfo object as an argument. If you use en-US or en-GB you should get what you want.

In fact the example on the page I linked to uses en-US and tr-TR (Turkey-Turkish) on the word "indigo" as an example of the differences.

Upvotes: 5

Related Questions