473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

string and pound symbol

Hi,

I have a char* string where I assigned a string literal with the British
pound symbol, which is included in the extended ASCII, at least on my OS.
However, when I cout the string, I get a modified u in place of the pound
symbol. Why is that? If I output the ASCII code of the pound symbol it
outputs just fine--but not when in a char*.
Feb 5 '06 #1
3 5096
* quat:

I have a char* string where I assigned a string literal with the British
pound symbol, which is included in the extended ASCII, at least on my OS.
Well, there are numerous _different_ extensions of ASCII; nearly all
character sets in common use are extensions of ASCII.

However, when I cout the string, I get a modified u in place of the pound
symbol. Why is that?
Sounds platform-specific; just on the off-chance that it's relevant, see
<http://home.no.net/dubjai/win32cpptut/html/w32cpptut_01_02_06.html>.

If I output the ASCII code of the pound symbol it
outputs just fine--but not when in a char*.


Hum, well, _now_ it sounds more like a coding problem. But you don't
show any code. Sorry, no code, no help (no arms, no cake!).

Cheers,

- Alf

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 5 '06 #2
Tom
On Sat, 4 Feb 2006 19:39:20 -0800, "quat" <sp**@void.com> wrote:
Hi,

I have a char* string where I assigned a string literal with the British
pound symbol, which is included in the extended ASCII, at least on my OS.
However, when I cout the string, I get a modified u in place of the pound
symbol. Why is that? If I output the ASCII code of the pound symbol it
outputs just fine--but not when in a char*.


Interesting challenge.

I suggest a help search on the following:

1) extended ascii
2) cin
3) LC_CTYPE
4) setlocale
5) code pages

The information about "setlocale" is where I believe you will be lead
to the solution.

I am interested in hearing if you have success with setlocale. I have
never had the need for it before; thus, I am very curious.

Your country code appears to be "gbr". The following listing was found
in help:

-------------------

The following is a list of country/regions strings recognized by
setlocale. Strings for countries/regions that are not supported by the
operating system are not accepted by setlocale. Three-letter
country/region-name codes are from ISO/IEC (International Organization
for Standardization, International Electrotechnical Commission)
specification 3166.

Country/Region Country/Region String
Australia "aus" or "australia"
Austria "austria" or "aut"
Belgium "bel" or "belgium"
Brazil "bra" or "brazil"
Canada "can" or "canada"
Czech Republic "cze" or "czech"
Denmark "denmark" or "dnk"
Finland "fin" or "finland"
France "fra" or "france"
Germany "deu" or "germany"
Greece "grc" or "greece"
Hong Kong "hkg", "hong kong", or "hong-kong"
Hungary "hun" or "hungary"
Iceland "iceland" or "isl"
Ireland "ireland" or "irl"
Italy "ita" or "italy"
Japan "japan" or "jpn"
Mexico "mex" or "mexico"
Netherlands "nld", "holland", or "netherlands"
New Zealand "new zealand", "new-zealand", "nz", or "nzl"
Norway "nor" or "norway"
People’s Republic of China "china", "chn", "pr china", or "pr-china"
Poland "pol" or "poland"
Portugal "prt" or "portugal"
Russia "rus" or "russia"
Singapore "sgp" or "singapore"
Slovak Repubic "svk" or "slovak"
South Korea "kor", "korea", "south korea", or "south-korea"
Spain "esp" or "spain"
Sweden "swe" or "sweden"
Switzerland "che" or "switzerland"
Taiwan "taiwan" or "twn"
Turkey "tur" or "turkey"
United Kingdom "britain", "england", "gbr", "great britain", "uk",
"united kingdom", or "united-kingdom"
United States of America "america", "united states", "united-states",
"us", or "usa"

------------------------

- Tom

Feb 5 '06 #3
TB
quat sade:
Hi,

I have a char* string where I assigned a string literal with the British
pound symbol, which is included in the extended ASCII, at least on my OS.
However, when I cout the string, I get a modified u in place of the pound
symbol. Why is that? If I output the ASCII code of the pound symbol it
outputs just fine--but not when in a char*.


I guess you're on Windows. Understand that a lot of things happen
between your call to std::cout and the displayed character.

You need to make up your mind about which "extended ascii" - charset
you intend on using.

Latin-1 is a subset of Unicode, and Ascii is a subset of Latin-1.
If you use Latin-1 and your host environment supports either that or
Unicode, then you should be able to get the correct character on the
display, otherwise some translation tables might be necessary,
depending on platform specific issues.

Here's a solution we used several years ago to make it work. It's not
in any way a perfect solution, and might be flawed, but testing it
just now, it still works on Windows XP.

http://www.cypher.nu/conasc.h

#include "conasc.h"
#include <ostream>
int main() {
conasc::enter();
std::cout<<'£';
conasc::leave();
return 0;
}

Prints '£' on the console instead of 'ù' as it would normally.
IIRC, it uses a translation table based on trail-and-error, and
switches the stream buffer used by std::cout with its own.
Most likely not thread-safe. But perhaps interesting. It's probably
better to construct a new stream with this translating buffer instead
of using conasc::enter() and conasc::leave().

--
TB @ SWEDEN
Feb 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Robert Zierhofer | last post by:
hi there, it seems as if i can´t convert the euro and pound sign to their html equivalents. i tried eregi_replace("€", "&euro;", $haystack); eregi_replace("£", "&pound;", $haystack); as...
14
by: Vic Russell | last post by:
Hi, I'm trying to get the British pound (£) symbol through LibXML and just get "£" instead. Any ideas? Vic
5
by: Waldy | last post by:
Hi there, I am using the .Net XML Serialization classes to create XML strings. This has been working fine up until the point that one of the strings contained a pound sterling symbol. The...
3
by: Paul Hadfield | last post by:
All, When I use system.IO.StreamWriter to write append a string to file that contains the GBP pound symbol, I notice that it also appends an extra character before the pond symbol. Yet when I...
2
by: junk | last post by:
Hi, Sorry if this has been asked before, and apologise if this is the wrong NG. I am using PHP 5.0.5 and Apache 2.0.54 in a Win2k environment. Lately I have been playng with RSS feeds. I...
5
by: Jim Carlock | last post by:
(1) test.php?test_key=test_value $_SERVER returns /test/test.php $_SERVER returns /test/test.php?test_key=test+value $_SERVER returns test_key=test+value (2)...
5
by: ramaswamynanda | last post by:
Hello, I have a currency field on my form. The default formats for this field are dollar, euro. There is no pound symbol.....How do i put in a currency format, having the pound sign. Any help...
107
by: bmshivaraj | last post by:
Hi, Could any one tell me how to convert a unsigned long value into string (char *) ? In C++ there is a function _ultoa so wanted a similar one in C . Regards, Shivaraj
1
by: Darren Mansell | last post by:
Hi. I'm relatively new to python so please be gentle :) I'm trying to write a £ symbol to an MS SQL server using pymsssql . This works but when selecting the data back (e.g. using SQL...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.