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











share|improve this question
























  • 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 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















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











share|improve this question
























  • 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 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













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











share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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


















  • 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 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
















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












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.






share|improve this answer








New contributor




Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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
































    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.






    share|improve this answer








    New contributor




    Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      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.






      share|improve this answer








      New contributor




      Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        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.






        share|improve this answer








        New contributor




        Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        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.







        share|improve this answer








        New contributor




        Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered Nov 4 at 10:38









        Klaus Gütter

        1414




        1414




        New contributor




        Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Klaus Gütter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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




















































































            這個網誌中的熱門文章

            Tangent Lines Diagram Along Smooth Curve

            Yusuf al-Mu'taman ibn Hud

            Zucchini