How to include special characters in string?
![]()
In C++ programs, sometimes you’ve to add special chars to your strings. For instance a copyright message – “Copyright © WeSeeTips.com”. If your editor like Visual Studio support unicode, you can directly paste it to the source. But not all editors are unicode aware. So what’s the safest method?
![]()
You can use C++ escape sequence – \x. The \x followed by hexadecimal value of char will insert that char to the string. For instance the hex of © is oxA9. See how it can be added to a string.
// 0xA9 is the hex for copyright symbol.
const TCHAR* pCopyright = _T("Copyright \xA9 WeSeeTips.com");
AfxMessageBox( pCopyright );
![]()
Its worth reading about trigraphs chars at this moment.
http://weseetips.com/2008/03/25/trigraph-char-sequences-in-c-c/
![]()
Targeted Audience – Beginners.
Thanks! I would have never found this if it wasn’t for this one webpage! These sort of niche c++ things are always tricky.
Thanks a lot, this info was very useful
Hi Mithra,
I’m so happy to know that!
Best Regards,
Jijo.