Can someone please explain to me why, if I type 'Ni(ALT-164)A' at the
windows prompt, I get '[c:\]Niña', but if my program does this:
int main(){
std::string str("Niña");
std::cout << str << std::endl;
return 0;
}
I get [C:\]Ni±a
Can someone please, please, give me a hand understanding this
problem?!!
TIA 5 1443
jalkadir wrote: Can someone please explain to me why, if I type 'Ni(ALT-164)A' at the windows prompt, I get '[c:\]Niña', but if my program does this: int main(){ std::string str("Niña"); std::cout << str << std::endl; return 0; }
I get [C:\]Ni±a
Can someone please, please, give me a hand understanding this problem?!!
TIA
Perhaps different fonts are being used in the two windows?
Cheers! --M
jalkadir wrote: Can someone please explain to me why, if I type 'Ni(ALT-164)A' at the windows prompt, I get '[c:\]Niña', but if my program does this: int main(){ std::string str("Niña"); std::cout << str << std::endl; return 0; }
I get [C:\]Ni±a
Can someone please, please, give me a hand understanding this problem?!!
I don't know what the problem is. Some conversion is applied somewhere,
but it doesn't say where and how. I think the contents of string literals
are only specified in "Basic character set", and ALT-164 is "Extended
ASCII" (if your basic set is ASCII). The behaviour is essentially
undefined unless you use the proper escape notation:
#include <vector>
#include <string>
#include <iostream>
int main(){
std::string str("Ni\xa4" "a"); // Niña
std::cout << str << std::endl;
return 0;
}
V
Victor Bazarov wrote: [redacted]
int main(){ std::string str("Ni\xa4" "a"); // Niña
std::string str("Ni\0244a") ; // as an alternative std::cout << str << std::endl; return 0; }
On Tue, 18 Oct 2005 11:06:07 -0700, jalkadir wrote: Can someone please explain to me why, if I type 'Ni(ALT-164)A' at the windows prompt, I get '[c:\]Niña', but if my program does this: int main(){ std::string str("Niña");
Try this:
1) At a command prompt, type:
echo Ni(ALT-164)A > foo.txt
2) Open foo.txt in your source code editor.
3) Now type the same sequence into your source code editor in the same
file. You will see two different characters.
4) Save the file back and close it.
5) If you're using Visual Studio, open the file in binary mode. Otherwise,
use Debug.
You'll see:
4e 69 a4 61 0d 0a
4e 69 f1 61 0d 0a
They're different characters...
Victor's suggestion looks like it will work.
- Jay
On 18 Oct 2005 11:10:25 -0700, "mlimber" <ml*****@gmail. com> wrote: jalkadir wrote: Can someone please explain to me why, if I type 'Ni(ALT-164)A' at the windows prompt, I get '[c:\]Niña', but if my program does this: int main(){ std::string str("Niña"); std::cout << str << std::endl; return 0; }
I get [C:\]Ni±a
Can someone please, please, give me a hand understanding this problem?!!
TIA
Perhaps different fonts are being used in the two windows?
Cheers! --M
This is *Off-Topic*, as it is os-dependent, but the answer follows,
hope it helps.
I deduce from what you write that you are programming in MSWindows.
You are writing the program in some windows-based IDE, where the
charcater set is unicode and/or Windows-1252. In it, 'ñ' has the code
\xf1 and 'Ñ' has the code \xd1.
When you open a console, the character set is another really
different: it is the one that IBM devised for PC some decades ago, and
it is named somethiong like ASSCVII code page 437. In it, the codes
for 'ñ' and 'Ñ' are \xa4 and \xa5, respectively. This characetr set
may be seen at Start | All programs | Accessories | System tools |
Character set, and selecting Terminal font. Well, the exact location
and name of the tool may be slightly different, I am translating form
spanish.
So, you must use some especial means to convert from one code to the
other: either write the characters by escap seuqences, or use the MS
functions CharToOem and CharToOemBuff (serach at msdn.microsoft. com)
Saludos,
Zara This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gerson Kurz |
last post by:
AAAAAAAARG I hate the way python handles unicode. Here is a nice
problem for y'all to enjoy: say you have a variable thats unicode
directory = u"c:\temp"
Its unicode not because you want it to, but because its for example
read from _winreg which returns unicode.
You do an os.listdir(directory). Note that all filenames returned are
now unicode. (Change introduced I believe in 2.3).
|
by: krammer |
last post by:
Hello,
I have the following questions that I have not been able to find any
*good* answers for. Your help would me much appreciated!, fyi, I am a
Java XML guy and I have no experience with SGML so my questions will
probably be XML biased.
1) Is is possible to have Unicode text inside an SGML file?
an example would be something like this.......
|
by: webdev |
last post by:
lo all,
some of the questions i'll ask below have most certainly been discussed
already, i just hope someone's kind enough to answer them again to help
me out..
so i started a python 2.3 script that grabs some web pages from the web,
regex parse the data and stores it localy to xml file for further use..
at first i had no problem using python minidom and everything concerning
|
by: Neil Schemenauer |
last post by:
python-dev@python.org.]
The PEP has been rewritten based on a suggestion by Guido to change
str() rather than adding a new built-in function. Based on my
testing, I believe the idea is feasible. It would be helpful if
people could test the patched Python with their own applications and
report any incompatibilities.
PEP: 349
|
by: Wolfgang Draxinger |
last post by:
I understand that it is perfectly possible to store UTF-8 strings
in a std::string, however doing so can cause some implicaions.
E.g. you can't count the amount of characters by length() |
size(). Instead one has to iterate through the string, parse all
UTF-8 multibytes and count each multibyte as one character.
To address this problem the GTKmm bindings for the GTK+ toolkit
have implemented a own string class Glib::ustring...
| |
by: PvdK |
last post by:
Hello,
Although a lot of postings in the past discuss the subject of A2000
and Unicode support, I couldn't find what I was looking for.
My institute is compiling a dictionary of early middle dutch. The
sources used for this dictionary contain a lot of very specific
characters. Many of them are not available in current font sets, so we
made them ourselves (unicode). Now they have to be used in Access.
What I want to know is if it is...
|
by: Csaba Gabor |
last post by:
If I do alert(encodeURI(String.fromCharCode(250)));
(in FF 1.5+ or IE6 on my winXP Pro) then I get: %C3%BA
Now I was sort of expecting something like %u... (and a single (4
digit?) unicode hex character num). Is that something for the future,
or am I guaranteed that all % encodings (from encodeURI) will have
exactly two hex digits following?
Perhaps someone could shed some light on this or point me to quality
site. Be gentle, I know...
|
by: Terry Hancock |
last post by:
I still run into my own ignorance a lot with unicode in Python.
Is it possible to define some combination of __repr__, __str__,
and/or __unicode__ so that the unicode() wrapper isn't necessary
in this statement:
<GLOSS: é’ã„, cl=None, {'wd': u'\u9752\u3044'}>
(i.e. can I make it so that the object that print gets is already
unicode, so that the label 'é’ã„' will print readably?)
|
by: Donn Ingle |
last post by:
Hello,
I hope someone can illuminate this situation for me.
Here's the nutshell:
1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale.
2. If this returns "C" or anything without 'utf8' in it, then things start
to go downhill:
2a. The app assumes unicode objects internally. i.e. Whenever there is
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |