How do I get a non lowercase string after quotes in the titlecase condition
up vote
1
down vote
favorite
In my article titles, I use CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
but I think, it is not working after double quotes. At least for Turkish.
For example, an article's title like this:
KİRA PARASININ ÖDENMEMESİ NEDENİYLE YAPILAN "İLAMSIZ TAHLİYE"
TAKİPLERİNDE "TAKİP TALEBİ"NİN İÇERİĞİ.
After using the method like this:
private static string TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
var art_title = textbox1.Text.TitleCase();
It returns
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye"
Takiplerinde "Takip Talebi"Nin İçeriği.
The problem is here. Because it must be like this:
... "Takip Talebi"nin ...
but it is like this:
... "Takip Talebi"Nin ...
What's more, in the MS Word, when I click "Start a Word Initial Expense," it's transforming like that
... "Takip Talebi"Nin ...
But it is absolutely wrong. How can I fix this problem?
EDIT: Firstly I cut the sentence from the blanks and obtained the words. If a word includes double quote, it would get a lowercase string until the first space after the second double quote. Here is the idea:
private static string _TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
public static string TitleCase(this string str)
{
var words = str.Split(' ');
string sentence = null;
var i = 1;
foreach (var word in words)
{
var space = i < words.Length ? " " : null;
if (word.Contains("""))
{
// After every second quotes, it would get a lowercase string until the first space after the second double quote... But how?
}
else
sentence += word._TitleCase() + space;
i++;
}
return sentence?.Trim();
}
Edit - 2 After 3 Hours: After 9 hours, I found a way to solve the problem. I believe that it is absolutely not scientific. Please don't condemn me for this. If the whole problem is double quotes, I replace it with a number that I think it is unique or an unused letter in Turkish, like alpha, beta, omega etc. before sending it to the ToTitleCase
. In this case, the ToTitleCase
realizes the title transformation without any problems. Then I replace number or unused letter with double quotes in return time. So the purpose is realized. Please share it in here if you have a programmatic or scientific solution.
Here is my non-programmatic solution:
public static string TitleCase(this string str)
{
str = str.Replace(""", "9900099");
str = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
return str.Replace("9900099", """).Trim();
}
var art_title = textbox1.Text.TitleCase();
And the result:
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye" Takiplerinde "Takip Talebi"nin İçeriği
c# title-case
add a comment |
up vote
1
down vote
favorite
In my article titles, I use CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
but I think, it is not working after double quotes. At least for Turkish.
For example, an article's title like this:
KİRA PARASININ ÖDENMEMESİ NEDENİYLE YAPILAN "İLAMSIZ TAHLİYE"
TAKİPLERİNDE "TAKİP TALEBİ"NİN İÇERİĞİ.
After using the method like this:
private static string TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
var art_title = textbox1.Text.TitleCase();
It returns
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye"
Takiplerinde "Takip Talebi"Nin İçeriği.
The problem is here. Because it must be like this:
... "Takip Talebi"nin ...
but it is like this:
... "Takip Talebi"Nin ...
What's more, in the MS Word, when I click "Start a Word Initial Expense," it's transforming like that
... "Takip Talebi"Nin ...
But it is absolutely wrong. How can I fix this problem?
EDIT: Firstly I cut the sentence from the blanks and obtained the words. If a word includes double quote, it would get a lowercase string until the first space after the second double quote. Here is the idea:
private static string _TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
public static string TitleCase(this string str)
{
var words = str.Split(' ');
string sentence = null;
var i = 1;
foreach (var word in words)
{
var space = i < words.Length ? " " : null;
if (word.Contains("""))
{
// After every second quotes, it would get a lowercase string until the first space after the second double quote... But how?
}
else
sentence += word._TitleCase() + space;
i++;
}
return sentence?.Trim();
}
Edit - 2 After 3 Hours: After 9 hours, I found a way to solve the problem. I believe that it is absolutely not scientific. Please don't condemn me for this. If the whole problem is double quotes, I replace it with a number that I think it is unique or an unused letter in Turkish, like alpha, beta, omega etc. before sending it to the ToTitleCase
. In this case, the ToTitleCase
realizes the title transformation without any problems. Then I replace number or unused letter with double quotes in return time. So the purpose is realized. Please share it in here if you have a programmatic or scientific solution.
Here is my non-programmatic solution:
public static string TitleCase(this string str)
{
str = str.Replace(""", "9900099");
str = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
return str.Replace("9900099", """).Trim();
}
var art_title = textbox1.Text.TitleCase();
And the result:
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye" Takiplerinde "Takip Talebi"nin İçeriği
c# title-case
What's the meaning of this second"
in"Takip Talebi"Nin
? Is the second"
not ending the quotation started by the first one or why isn't there a blank in between?
– DanDan
Nov 4 at 10:12
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 4 at 10:17
This is not an issue with the TurkishCultureInfo
, other languages behave equally. The second"
indicates a new word. Maybe either get rid of it, reformat it, do a uncapitalisation for"
surrounded by letters with no blanks via Regex or come up with your ownToTitleCase()
alternative via extension method
– DanDan
Nov 4 at 10:29
@mjwills, Thank you very much. I edited my question 2 times.
– Colin Henricks
2 days ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
In my article titles, I use CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
but I think, it is not working after double quotes. At least for Turkish.
For example, an article's title like this:
KİRA PARASININ ÖDENMEMESİ NEDENİYLE YAPILAN "İLAMSIZ TAHLİYE"
TAKİPLERİNDE "TAKİP TALEBİ"NİN İÇERİĞİ.
After using the method like this:
private static string TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
var art_title = textbox1.Text.TitleCase();
It returns
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye"
Takiplerinde "Takip Talebi"Nin İçeriği.
The problem is here. Because it must be like this:
... "Takip Talebi"nin ...
but it is like this:
... "Takip Talebi"Nin ...
What's more, in the MS Word, when I click "Start a Word Initial Expense," it's transforming like that
... "Takip Talebi"Nin ...
But it is absolutely wrong. How can I fix this problem?
EDIT: Firstly I cut the sentence from the blanks and obtained the words. If a word includes double quote, it would get a lowercase string until the first space after the second double quote. Here is the idea:
private static string _TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
public static string TitleCase(this string str)
{
var words = str.Split(' ');
string sentence = null;
var i = 1;
foreach (var word in words)
{
var space = i < words.Length ? " " : null;
if (word.Contains("""))
{
// After every second quotes, it would get a lowercase string until the first space after the second double quote... But how?
}
else
sentence += word._TitleCase() + space;
i++;
}
return sentence?.Trim();
}
Edit - 2 After 3 Hours: After 9 hours, I found a way to solve the problem. I believe that it is absolutely not scientific. Please don't condemn me for this. If the whole problem is double quotes, I replace it with a number that I think it is unique or an unused letter in Turkish, like alpha, beta, omega etc. before sending it to the ToTitleCase
. In this case, the ToTitleCase
realizes the title transformation without any problems. Then I replace number or unused letter with double quotes in return time. So the purpose is realized. Please share it in here if you have a programmatic or scientific solution.
Here is my non-programmatic solution:
public static string TitleCase(this string str)
{
str = str.Replace(""", "9900099");
str = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
return str.Replace("9900099", """).Trim();
}
var art_title = textbox1.Text.TitleCase();
And the result:
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye" Takiplerinde "Takip Talebi"nin İçeriği
c# title-case
In my article titles, I use CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
but I think, it is not working after double quotes. At least for Turkish.
For example, an article's title like this:
KİRA PARASININ ÖDENMEMESİ NEDENİYLE YAPILAN "İLAMSIZ TAHLİYE"
TAKİPLERİNDE "TAKİP TALEBİ"NİN İÇERİĞİ.
After using the method like this:
private static string TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
var art_title = textbox1.Text.TitleCase();
It returns
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye"
Takiplerinde "Takip Talebi"Nin İçeriği.
The problem is here. Because it must be like this:
... "Takip Talebi"nin ...
but it is like this:
... "Takip Talebi"Nin ...
What's more, in the MS Word, when I click "Start a Word Initial Expense," it's transforming like that
... "Takip Talebi"Nin ...
But it is absolutely wrong. How can I fix this problem?
EDIT: Firstly I cut the sentence from the blanks and obtained the words. If a word includes double quote, it would get a lowercase string until the first space after the second double quote. Here is the idea:
private static string _TitleCase(this string str)
{
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
}
public static string TitleCase(this string str)
{
var words = str.Split(' ');
string sentence = null;
var i = 1;
foreach (var word in words)
{
var space = i < words.Length ? " " : null;
if (word.Contains("""))
{
// After every second quotes, it would get a lowercase string until the first space after the second double quote... But how?
}
else
sentence += word._TitleCase() + space;
i++;
}
return sentence?.Trim();
}
Edit - 2 After 3 Hours: After 9 hours, I found a way to solve the problem. I believe that it is absolutely not scientific. Please don't condemn me for this. If the whole problem is double quotes, I replace it with a number that I think it is unique or an unused letter in Turkish, like alpha, beta, omega etc. before sending it to the ToTitleCase
. In this case, the ToTitleCase
realizes the title transformation without any problems. Then I replace number or unused letter with double quotes in return time. So the purpose is realized. Please share it in here if you have a programmatic or scientific solution.
Here is my non-programmatic solution:
public static string TitleCase(this string str)
{
str = str.Replace(""", "9900099");
str = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str.ToLower());
return str.Replace("9900099", """).Trim();
}
var art_title = textbox1.Text.TitleCase();
And the result:
Kira Parasının Ödenmemesi Nedeniyle Yapılan "İlamsız Tahliye" Takiplerinde "Takip Talebi"nin İçeriği
c# title-case
c# title-case
edited 2 days ago
asked Nov 4 at 10:04
Colin Henricks
93252245
93252245
What's the meaning of this second"
in"Takip Talebi"Nin
? Is the second"
not ending the quotation started by the first one or why isn't there a blank in between?
– DanDan
Nov 4 at 10:12
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 4 at 10:17
This is not an issue with the TurkishCultureInfo
, other languages behave equally. The second"
indicates a new word. Maybe either get rid of it, reformat it, do a uncapitalisation for"
surrounded by letters with no blanks via Regex or come up with your ownToTitleCase()
alternative via extension method
– DanDan
Nov 4 at 10:29
@mjwills, Thank you very much. I edited my question 2 times.
– Colin Henricks
2 days ago
add a comment |
What's the meaning of this second"
in"Takip Talebi"Nin
? Is the second"
not ending the quotation started by the first one or why isn't there a blank in between?
– DanDan
Nov 4 at 10:12
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 4 at 10:17
This is not an issue with the TurkishCultureInfo
, other languages behave equally. The second"
indicates a new word. Maybe either get rid of it, reformat it, do a uncapitalisation for"
surrounded by letters with no blanks via Regex or come up with your ownToTitleCase()
alternative via extension method
– DanDan
Nov 4 at 10:29
@mjwills, Thank you very much. I edited my question 2 times.
– Colin Henricks
2 days ago
What's the meaning of this second
"
in "Takip Talebi"Nin
? Is the second "
not ending the quotation started by the first one or why isn't there a blank in between?– DanDan
Nov 4 at 10:12
What's the meaning of this second
"
in "Takip Talebi"Nin
? Is the second "
not ending the quotation started by the first one or why isn't there a blank in between?– DanDan
Nov 4 at 10:12
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 4 at 10:17
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 4 at 10:17
This is not an issue with the Turkish
CultureInfo
, other languages behave equally. The second "
indicates a new word. Maybe either get rid of it, reformat it, do a uncapitalisation for "
surrounded by letters with no blanks via Regex or come up with your own ToTitleCase()
alternative via extension method– DanDan
Nov 4 at 10:29
This is not an issue with the Turkish
CultureInfo
, other languages behave equally. The second "
indicates a new word. Maybe either get rid of it, reformat it, do a uncapitalisation for "
surrounded by letters with no blanks via Regex or come up with your own ToTitleCase()
alternative via extension method– DanDan
Nov 4 at 10:29
@mjwills, Thank you very much. I edited my question 2 times.
– Colin Henricks
2 days ago
@mjwills, Thank you very much. I edited my question 2 times.
– Colin Henricks
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Indeed, Microsoft documentation ToTitleCase states that ToTitleCase is (at least currently) not linguistically correct. In fact, it is REALLY hard to do this correctly (see these blog posts of the great Michael Kaplan: Sometimes, uppercasing sucks and "Michael, why does ToTitleCase suck so much?").
I'm not aware of any service or library providing a linguistically correct version.
So - unless you want to spend a lot of effort - you probably have to live with this inaccuracy.
New contributor
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Indeed, Microsoft documentation ToTitleCase states that ToTitleCase is (at least currently) not linguistically correct. In fact, it is REALLY hard to do this correctly (see these blog posts of the great Michael Kaplan: Sometimes, uppercasing sucks and "Michael, why does ToTitleCase suck so much?").
I'm not aware of any service or library providing a linguistically correct version.
So - unless you want to spend a lot of effort - you probably have to live with this inaccuracy.
New contributor
add a comment |
up vote
1
down vote
Indeed, Microsoft documentation ToTitleCase states that ToTitleCase is (at least currently) not linguistically correct. In fact, it is REALLY hard to do this correctly (see these blog posts of the great Michael Kaplan: Sometimes, uppercasing sucks and "Michael, why does ToTitleCase suck so much?").
I'm not aware of any service or library providing a linguistically correct version.
So - unless you want to spend a lot of effort - you probably have to live with this inaccuracy.
New contributor
add a comment |
up vote
1
down vote
up vote
1
down vote
Indeed, Microsoft documentation ToTitleCase states that ToTitleCase is (at least currently) not linguistically correct. In fact, it is REALLY hard to do this correctly (see these blog posts of the great Michael Kaplan: Sometimes, uppercasing sucks and "Michael, why does ToTitleCase suck so much?").
I'm not aware of any service or library providing a linguistically correct version.
So - unless you want to spend a lot of effort - you probably have to live with this inaccuracy.
New contributor
Indeed, Microsoft documentation ToTitleCase states that ToTitleCase is (at least currently) not linguistically correct. In fact, it is REALLY hard to do this correctly (see these blog posts of the great Michael Kaplan: Sometimes, uppercasing sucks and "Michael, why does ToTitleCase suck so much?").
I'm not aware of any service or library providing a linguistically correct version.
So - unless you want to spend a lot of effort - you probably have to live with this inaccuracy.
New contributor
New contributor
answered Nov 4 at 10:38
Klaus Gütter
1414
1414
New contributor
New contributor
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139632%2fhow-do-i-get-a-non-lowercase-string-after-quotes-in-the-titlecase-condition%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
What's the meaning of this second
"
in"Takip Talebi"Nin
? Is the second"
not ending the quotation started by the first one or why isn't there a blank in between?– DanDan
Nov 4 at 10:12
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 4 at 10:17
This is not an issue with the Turkish
CultureInfo
, other languages behave equally. The second"
indicates a new word. Maybe either get rid of it, reformat it, do a uncapitalisation for"
surrounded by letters with no blanks via Regex or come up with your ownToTitleCase()
alternative via extension method– DanDan
Nov 4 at 10:29
@mjwills, Thank you very much. I edited my question 2 times.
– Colin Henricks
2 days ago