Compare language special character












0















In other languages no English it is common to have a special character such as ñ in Spanish.



I have recently found myself wondering how can you compare two char such temporal == 'ñ'? Or temporal == char(-94) I have tried both and no one looks like working










share|improve this question




















  • 2





    The char type can be signed, unsigned or char. If signed, there may not be enough range for special characters. You may need to invest in wide characters or 16-bit values to represent the characters. Search the internet for "c++ wide characters" or "c++ multibyte characters".

    – Thomas Matthews
    Nov 29 '18 at 0:48






  • 4





    With ñ you need to understand what character set you're using. Likely one of these en.wikipedia.org/wiki/%C3%91 . Some representations of it take up two bytes. There's also 164 in the old "standard" extended ascii table, which is no longer standard, if it ever was, and there's "code pages" which replace it but have also fallen out of favor.

    – zzxyz
    Nov 29 '18 at 0:50











  • Why do you need to compare individual characters, or in general access individual characters of a string? It is almost never needed for non-text-processing applications. There is nothing special in these characters BTW.

    – n.m.
    Nov 29 '18 at 4:54













  • i need to process a spanish text, and implements a letter counter

    – Yunhao
    Nov 29 '18 at 10:49











  • Is this a school assignment? You should know that in Unicode accented characters can be represented in more than one way. First, as a letter followed by a separate combining accent character; and second, as a single pre-composed accented character. (Each character may occupy more than one byte). This may or may not be relevant for letter count, but it may break your word count if you are not careful.

    – n.m.
    Nov 29 '18 at 12:49
















0















In other languages no English it is common to have a special character such as ñ in Spanish.



I have recently found myself wondering how can you compare two char such temporal == 'ñ'? Or temporal == char(-94) I have tried both and no one looks like working










share|improve this question




















  • 2





    The char type can be signed, unsigned or char. If signed, there may not be enough range for special characters. You may need to invest in wide characters or 16-bit values to represent the characters. Search the internet for "c++ wide characters" or "c++ multibyte characters".

    – Thomas Matthews
    Nov 29 '18 at 0:48






  • 4





    With ñ you need to understand what character set you're using. Likely one of these en.wikipedia.org/wiki/%C3%91 . Some representations of it take up two bytes. There's also 164 in the old "standard" extended ascii table, which is no longer standard, if it ever was, and there's "code pages" which replace it but have also fallen out of favor.

    – zzxyz
    Nov 29 '18 at 0:50











  • Why do you need to compare individual characters, or in general access individual characters of a string? It is almost never needed for non-text-processing applications. There is nothing special in these characters BTW.

    – n.m.
    Nov 29 '18 at 4:54













  • i need to process a spanish text, and implements a letter counter

    – Yunhao
    Nov 29 '18 at 10:49











  • Is this a school assignment? You should know that in Unicode accented characters can be represented in more than one way. First, as a letter followed by a separate combining accent character; and second, as a single pre-composed accented character. (Each character may occupy more than one byte). This may or may not be relevant for letter count, but it may break your word count if you are not careful.

    – n.m.
    Nov 29 '18 at 12:49














0












0








0








In other languages no English it is common to have a special character such as ñ in Spanish.



I have recently found myself wondering how can you compare two char such temporal == 'ñ'? Or temporal == char(-94) I have tried both and no one looks like working










share|improve this question
















In other languages no English it is common to have a special character such as ñ in Spanish.



I have recently found myself wondering how can you compare two char such temporal == 'ñ'? Or temporal == char(-94) I have tried both and no one looks like working







c++






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 29 '18 at 4:51









GYaN

2,09731432




2,09731432










asked Nov 29 '18 at 0:27









YunhaoYunhao

136




136








  • 2





    The char type can be signed, unsigned or char. If signed, there may not be enough range for special characters. You may need to invest in wide characters or 16-bit values to represent the characters. Search the internet for "c++ wide characters" or "c++ multibyte characters".

    – Thomas Matthews
    Nov 29 '18 at 0:48






  • 4





    With ñ you need to understand what character set you're using. Likely one of these en.wikipedia.org/wiki/%C3%91 . Some representations of it take up two bytes. There's also 164 in the old "standard" extended ascii table, which is no longer standard, if it ever was, and there's "code pages" which replace it but have also fallen out of favor.

    – zzxyz
    Nov 29 '18 at 0:50











  • Why do you need to compare individual characters, or in general access individual characters of a string? It is almost never needed for non-text-processing applications. There is nothing special in these characters BTW.

    – n.m.
    Nov 29 '18 at 4:54













  • i need to process a spanish text, and implements a letter counter

    – Yunhao
    Nov 29 '18 at 10:49











  • Is this a school assignment? You should know that in Unicode accented characters can be represented in more than one way. First, as a letter followed by a separate combining accent character; and second, as a single pre-composed accented character. (Each character may occupy more than one byte). This may or may not be relevant for letter count, but it may break your word count if you are not careful.

    – n.m.
    Nov 29 '18 at 12:49














  • 2





    The char type can be signed, unsigned or char. If signed, there may not be enough range for special characters. You may need to invest in wide characters or 16-bit values to represent the characters. Search the internet for "c++ wide characters" or "c++ multibyte characters".

    – Thomas Matthews
    Nov 29 '18 at 0:48






  • 4





    With ñ you need to understand what character set you're using. Likely one of these en.wikipedia.org/wiki/%C3%91 . Some representations of it take up two bytes. There's also 164 in the old "standard" extended ascii table, which is no longer standard, if it ever was, and there's "code pages" which replace it but have also fallen out of favor.

    – zzxyz
    Nov 29 '18 at 0:50











  • Why do you need to compare individual characters, or in general access individual characters of a string? It is almost never needed for non-text-processing applications. There is nothing special in these characters BTW.

    – n.m.
    Nov 29 '18 at 4:54













  • i need to process a spanish text, and implements a letter counter

    – Yunhao
    Nov 29 '18 at 10:49











  • Is this a school assignment? You should know that in Unicode accented characters can be represented in more than one way. First, as a letter followed by a separate combining accent character; and second, as a single pre-composed accented character. (Each character may occupy more than one byte). This may or may not be relevant for letter count, but it may break your word count if you are not careful.

    – n.m.
    Nov 29 '18 at 12:49








2




2





The char type can be signed, unsigned or char. If signed, there may not be enough range for special characters. You may need to invest in wide characters or 16-bit values to represent the characters. Search the internet for "c++ wide characters" or "c++ multibyte characters".

– Thomas Matthews
Nov 29 '18 at 0:48





The char type can be signed, unsigned or char. If signed, there may not be enough range for special characters. You may need to invest in wide characters or 16-bit values to represent the characters. Search the internet for "c++ wide characters" or "c++ multibyte characters".

– Thomas Matthews
Nov 29 '18 at 0:48




4




4





With ñ you need to understand what character set you're using. Likely one of these en.wikipedia.org/wiki/%C3%91 . Some representations of it take up two bytes. There's also 164 in the old "standard" extended ascii table, which is no longer standard, if it ever was, and there's "code pages" which replace it but have also fallen out of favor.

– zzxyz
Nov 29 '18 at 0:50





With ñ you need to understand what character set you're using. Likely one of these en.wikipedia.org/wiki/%C3%91 . Some representations of it take up two bytes. There's also 164 in the old "standard" extended ascii table, which is no longer standard, if it ever was, and there's "code pages" which replace it but have also fallen out of favor.

– zzxyz
Nov 29 '18 at 0:50













Why do you need to compare individual characters, or in general access individual characters of a string? It is almost never needed for non-text-processing applications. There is nothing special in these characters BTW.

– n.m.
Nov 29 '18 at 4:54







Why do you need to compare individual characters, or in general access individual characters of a string? It is almost never needed for non-text-processing applications. There is nothing special in these characters BTW.

– n.m.
Nov 29 '18 at 4:54















i need to process a spanish text, and implements a letter counter

– Yunhao
Nov 29 '18 at 10:49





i need to process a spanish text, and implements a letter counter

– Yunhao
Nov 29 '18 at 10:49













Is this a school assignment? You should know that in Unicode accented characters can be represented in more than one way. First, as a letter followed by a separate combining accent character; and second, as a single pre-composed accented character. (Each character may occupy more than one byte). This may or may not be relevant for letter count, but it may break your word count if you are not careful.

– n.m.
Nov 29 '18 at 12:49





Is this a school assignment? You should know that in Unicode accented characters can be represented in more than one way. First, as a letter followed by a separate combining accent character; and second, as a single pre-composed accented character. (Each character may occupy more than one byte). This may or may not be relevant for letter count, but it may break your word count if you are not careful.

– n.m.
Nov 29 '18 at 12:49












1 Answer
1






active

oldest

votes


















0














I figure your most likely scenario is you get to choose the character set, and you have a console app. If not, the only thing you'll want to pay attention to is the first sentence, and the L in front of strings in the code. And wchar_t being your character type..



Make sure the project properties under General are set to "Use Unicode Character Set". And also I'd forgotten a little trick with console apps. You have to set the console mode to unicode for some bizarre reason (probably backward compatibility). With UI apps, this is a non-issue.



#include <fcntl.h>
#include <io.h>


...



          _setmode(_fileno(stdout), _O_U16TEXT); //use utf-16, like every other Windows system defaults to
_setmode(_fileno(stdin), _O_U16TEXT);
wchar_t n = 0x00f1; //see https://www.fileformat.info/info/charset/UTF-16/list.htm
_tprintf(L"%cn", n); //(or use wprintf explicitly)
_tprintf(L"ññññññññññn");
wcout << L"ñn";


I hope this is at least a little helpful.






share|improve this answer
























    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',
    autoActivateHeartbeat: false,
    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%2f53530123%2fcompare-language-special-character%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I figure your most likely scenario is you get to choose the character set, and you have a console app. If not, the only thing you'll want to pay attention to is the first sentence, and the L in front of strings in the code. And wchar_t being your character type..



    Make sure the project properties under General are set to "Use Unicode Character Set". And also I'd forgotten a little trick with console apps. You have to set the console mode to unicode for some bizarre reason (probably backward compatibility). With UI apps, this is a non-issue.



    #include <fcntl.h>
    #include <io.h>


    ...



              _setmode(_fileno(stdout), _O_U16TEXT); //use utf-16, like every other Windows system defaults to
    _setmode(_fileno(stdin), _O_U16TEXT);
    wchar_t n = 0x00f1; //see https://www.fileformat.info/info/charset/UTF-16/list.htm
    _tprintf(L"%cn", n); //(or use wprintf explicitly)
    _tprintf(L"ññññññññññn");
    wcout << L"ñn";


    I hope this is at least a little helpful.






    share|improve this answer




























      0














      I figure your most likely scenario is you get to choose the character set, and you have a console app. If not, the only thing you'll want to pay attention to is the first sentence, and the L in front of strings in the code. And wchar_t being your character type..



      Make sure the project properties under General are set to "Use Unicode Character Set". And also I'd forgotten a little trick with console apps. You have to set the console mode to unicode for some bizarre reason (probably backward compatibility). With UI apps, this is a non-issue.



      #include <fcntl.h>
      #include <io.h>


      ...



                _setmode(_fileno(stdout), _O_U16TEXT); //use utf-16, like every other Windows system defaults to
      _setmode(_fileno(stdin), _O_U16TEXT);
      wchar_t n = 0x00f1; //see https://www.fileformat.info/info/charset/UTF-16/list.htm
      _tprintf(L"%cn", n); //(or use wprintf explicitly)
      _tprintf(L"ññññññññññn");
      wcout << L"ñn";


      I hope this is at least a little helpful.






      share|improve this answer


























        0












        0








        0







        I figure your most likely scenario is you get to choose the character set, and you have a console app. If not, the only thing you'll want to pay attention to is the first sentence, and the L in front of strings in the code. And wchar_t being your character type..



        Make sure the project properties under General are set to "Use Unicode Character Set". And also I'd forgotten a little trick with console apps. You have to set the console mode to unicode for some bizarre reason (probably backward compatibility). With UI apps, this is a non-issue.



        #include <fcntl.h>
        #include <io.h>


        ...



                  _setmode(_fileno(stdout), _O_U16TEXT); //use utf-16, like every other Windows system defaults to
        _setmode(_fileno(stdin), _O_U16TEXT);
        wchar_t n = 0x00f1; //see https://www.fileformat.info/info/charset/UTF-16/list.htm
        _tprintf(L"%cn", n); //(or use wprintf explicitly)
        _tprintf(L"ññññññññññn");
        wcout << L"ñn";


        I hope this is at least a little helpful.






        share|improve this answer













        I figure your most likely scenario is you get to choose the character set, and you have a console app. If not, the only thing you'll want to pay attention to is the first sentence, and the L in front of strings in the code. And wchar_t being your character type..



        Make sure the project properties under General are set to "Use Unicode Character Set". And also I'd forgotten a little trick with console apps. You have to set the console mode to unicode for some bizarre reason (probably backward compatibility). With UI apps, this is a non-issue.



        #include <fcntl.h>
        #include <io.h>


        ...



                  _setmode(_fileno(stdout), _O_U16TEXT); //use utf-16, like every other Windows system defaults to
        _setmode(_fileno(stdin), _O_U16TEXT);
        wchar_t n = 0x00f1; //see https://www.fileformat.info/info/charset/UTF-16/list.htm
        _tprintf(L"%cn", n); //(or use wprintf explicitly)
        _tprintf(L"ññññññññññn");
        wcout << L"ñn";


        I hope this is at least a little helpful.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 3 '18 at 20:17









        zzxyzzzxyz

        2,2291725




        2,2291725
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53530123%2fcompare-language-special-character%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)