printing multiplication sign in c++ - c++

In Qt for setting the label of a button to be the "Multiplication sign" (not astrisk(*)) this is used :
Button *myButton = new Button("\303\227");
I don't know anything about "\303\227". Also the code below will not print "Multiplication sign" :
cout << "\303\227" ;
I could not search for it cause I had no "keywords".
I need some keywords and some information about this number and why cannot it be printed with cout object.
Also i didn't want to add Qt tag for this question cause I think this is not much Qt related.
Thanks in advance.

those are called octal codes for UTF-8 characters, and I believe C++ has no useful native Unicode support. However, you may refer to this question
for how to use unicode in qt.
if you just want the multiplication symbol you may use this “×” U+00D7 or this U+2715 ✕

Related

Store an Ascii char in an array in c++

first of all thanks for reading ^ ^
ok, so I'm making an easy menu for a console project
after I created the options I wanted to add the char(240) as another option but I can't figure out how to declare it I cant just write ≡ because Dev++ won't let me write it, the code is:
char *menu_list[6] = { " SYMBOL GOES HERE "," View ", " Edit ", " Search ", " Reset", " Quit " };
does anyone know how to do this? or if I'm doin it all wrong, can you tell me the right way to do it?
i'm forced to make it work on windows, i can
cout << char(240);
and it works right, but I cannot store that same symbol into menu_list
also I got the code from here
http://www.theasciicode.com.ar/extended-ascii-code/hyphen-ascii-code-240.html
There was a deleted answer that had the correct response: use "\xf0" to represent the character.
Ordinarily you would need to know which code page is being used by Windows to know how a character code maps to a particular character on screen. However by doing the research yourself, you already know that the decimal value 240 represents the character you need. That decimal 240 is the same as hex f0, and the way to embed a hex literal value in a string is to prefix it with \x.
As noted in the link you posted, these codes correspond to code page 437. This is the one used by the command window in English versions of Windows; I'm not sure if alternate language versions of Windows use anything different. Calling this "extended ASCII" is confusing, since there have been many attempts to extend ASCII over the years and none of them are the same.

How to insert check mark "✓" in std::string in c++ programming using VS2010

In one of my application I'm developing in c++, I have to display "✓" mark. For that I need to first insert the same in a std::string or in a char. But when I do that, I'm getting a "?" mark as output. I'm using VS2010 to code. Please suggest how to solve the same. Thanks in advance.
There seems to be some basic misunderstanding.
The checkmark character is Unicode 0x2713. You cannot store it as a single character in std::string. The maximum value for a char is 0xff (255). It won't fit.
If you are developing a GUI using C++ for Windows then I would guess MFC. However if you are using std::string then perhaps that's not so. Some choices:
For MFC, you can rebuild your application in UNICODE mode. Then chars are short (16 bits) and your checkmark will fit fine.
You could use std::wstring instead of string. That means changes to existing code.
You could use UTF-8, which replaces the character by a multi-byte sequence. Not recommended in Windows, even if you think you know what you're doing. Very unfriendly.
In any case, if you are using GUI and dialog boxes you will have to make sure they are Unicode dialog boxes or nothing will work.
With a few more details, we could give more specific advice.
you can insert check mark in your console using C++ using the following code
cout << " (\xfb) "<<endl;
Output:
(√)

Disable commas in cout?

In a project I am currently working on I link to a proprietary dynamic library. As soon as I run the library's initialize function, the behavior of logging and printing of numbers changes.
Commas have been inserted at every third decimal. Ie.
cout << 123456789 << endl
used to print out 123456789 and now it prints 123,456,789. This is horribly annoying, because this behavior is not what I want.
After some research I suspect a locale issue. I have tried using this line of code after calling the initialize function
setlocale(LC_ALL,"C");
thinking it might reset my local to the default; but to no avail. The commas persist!!
What am I missing?
I have posted a related follow on question here.
You can set the locale for a stream, independent of the locale that's set with setlocale. Try std::cout.imbue(std::locale("C"));
If you just want to get rid of the commas, you could also replace the current std::numpunct which is probably causing it with the default one which does not override do_grouping.
std::cout.imbue(std::locale(std::cout.getloc(), new std::numpunct<char>()));

Printing arabic string in c++

I'm beginner in C++
I'd like to print Arabic statement in C++ using Borland C, but I failed , I also tried to save the file as UTF-8 but it didn't help.
So please if any one knows anything about this or about what is the problem or how to configure the compiler to print Arabic please help me.
#include<iostram.h>
#include<conio.h>
void main()
{
clrscr();
char x [5] = {'ا','ح','م','د'};
for(int i = 0; i< 5; i++)
cout << x[i];
getche();
}
First of all, you are assuming that your source code can contain Arabic characters. This is a very bad idea, and depends on the assumption that the compiler is interpreting your source file in the same code page as your editor is writing it in.
The safest way to handle Arabic or other arbitrary Unicode in Windows C++ is to compile with _UNICODE, declare variables of wchar_t (and friends), and use Unicode constants like '\u6041' for your Arabic characters. If you must do things with 'char', you will have to come up with the multi-byte \x sequences in the right code page for your Arabic characters, and deal with the fact that a single char can't hold an Arabic character in UTF-8.
Finally, since you are using cout, this will only show you Arabic if the current code page of your DOS box is an Arabic code page.
If your BorlandC++ is under DOS
By default you have not any character set to show it as Arabic. But those days, there were applications which change extended ASCII characters to other languages such as Arabic, Persian, ... .
Steps you should do:
If you are using Windows Vista/7+, first you should use DosBox (you need Fullscreen-mode)
You must change the default ASCII font table in memory
Something like vegaf.com which defines Persian/Arabic alpha-beta
Note: UTF-8 is undefined for this system
C++11 is the only C++ standard that can offer native support for UTF-8 ( and other UTF charsets ) encoding.
in pre C++11 releases you can simply use a third part library if you need UTF-8 support like this one .

How to get decimal value of a unicode character in c++

For one of my opensource projects, i need to compute the decimal equivalent of a given unicode character.
For example if tamil character L'அ' is given, the output should be 2949 .
I am using c++ in Qt environment. I googled and could not find a solution for this. Please help if you know a solution for this.
Use the unicode() method of the QChar object (which you can get e.g. with the at method of a QString, if a QString is what you have to start with).
cout << (int)c
that's it
void print_decimal(wchar_t character)
{
std::cout << int(character);
}