473,511 Members | 10,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

warning: multi-character character constant...help me!

Hi! I should convert the accented letters of a string in the correspondent
letters not accented. But when I compile with -Wall it give me:

warning: multi-character character constant

Do the problem is the charset? How I can avoid this warning? But the worst
thing isn't the warning, but that the program doesn't work! The program
execute all other operations well, but it don't print the converted
letters: for example, in the string "licia colò" (with finally o accented),
instead giving in stdout "licia colo" (without finally o accented), how
should be, print "licia col ", with two spaces.
The code is this:

<CODE>

93 switch(s[i]) {
94 case 'Ã*':
95 t[i] = 'a';
96 break;
97 case 'è': case 'é':
98 t[i] = 'e';
99 break;
100 case 'ì':
101 t[i] = 'i';
102 break;
103 case 'ò':
104 t[i] = 'o';
105 break;
106 case 'ù':
107 t[i] = 'u';
108 break;
109 default:
110 break;
111 }

</CODE>

Between the apexes there are the accented letters. I try also with sprintf(t
+ i, "a") instead of t[i] = 'a', but it's the same thing. If instead of
accented letters I try to insert the unaccented letters, all works good.
The output of the gcc is this:

<OUTPUT>

[mimmo@localhost mimmo]$ gcc -Wall p.c -o p
p.c:94:38: warning: multi-character character constant
p.c:97:38: warning: multi-character character constant
p.c:97:49: warning: multi-character character constant
p.c:100:38: warning: multi-character character constant
p.c:103:38: warning: multi-character character constant
p.c:106:38: warning: multi-character character constant
[mimmo@localhost mimmo]$

</OUTPUT>

I hope anyone can give me an help, before than I drop the computer out
window!
Nov 14 '05 #1
4 17821
"mimmo" <-w*********@libero.it> wrote in message
news:ZZ**********************@twister2.libero.it.. .
Hi! I should convert the accented letters of a string in the correspondent
letters not accented. But when I compile with -Wall it give me:

warning: multi-character character constant

Do the problem is the charset? How I can avoid this warning? But the worst
thing isn't the warning, but that the program doesn't work! The program
execute all other operations well, but it don't print the converted
letters: for example, in the string "licia colò" (with finally o accented), instead giving in stdout "licia colo" (without finally o accented), how
should be, print "licia col ", with two spaces.
The code is this:

<CODE>

93 switch(s[i]) {
94 case 'à':
95 t[i] = 'a';
96 break;
97 case 'è': case 'é':
98 t[i] = 'e';
99 break;
100 case 'ì':
101 t[i] = 'i';
102 break;
103 case 'ò':
104 t[i] = 'o';
105 break;
106 case 'ù':
107 t[i] = 'u';
108 break;
109 default:
110 break;
111 }

</CODE>


Your compiler apparently doesn't like the accented characters. If you are
writing your translation for a specific codepage, you can use the relevant
character codes (e.g. 0xa0 for a acute). You could also improve your code by
using translation tables instead of a hardcoded switch, that way you have
your way open for multiple codepages.

Peter
Nov 14 '05 #2
> Your compiler apparently doesn't like the accented characters.

My compiler is gcc 3.3.2, how is possible the problem is the compiler?
Anyway I try to use the relevant character codes. Thank you!

Nov 14 '05 #3
"Peter Pichler" <pi*****@pobox.sk> writes:
"mimmo" <-w*********@libero.it> wrote in message
news:ZZ**********************@twister2.libero.it.. .
Hi! I should convert the accented letters of a string in the correspondent
letters not accented. But when I compile with -Wall it give me:

warning: multi-character character constant [...] 106 case 'ù':
107 t[i] = 'u';
108 break;
[...] Your compiler apparently doesn't like the accented characters. If you are
writing your translation for a specific codepage, you can use the relevant
character codes (e.g. 0xa0 for a acute). You could also improve your code by
using translation tables instead of a hardcoded switch, that way you have
your way open for multiple codepages.


The fact that the message warns about a "multi-character character
constant" (the kind of warning I'd expect for something like 'xy'), I
don't think it's *just* a matter of not liking accented characters.
My best guess is that you're using a UTF-8 encoding, which encodes
Unicode characters in multiple bytes. Your text editor is correctly
interpreting the UTF-8 sequences and displaying them for you as
accented characters, but gcc apparently doesn't handle them.

gcc may have an option to accept UTF-8 in source files; check the gcc
documentation. Or you may be able to translate your UTF-8 source
files to something like ISO-8859-1, which represents each character as
a single byte (but doesn't handle the full range of Unicode).

If you can't find the details in your documentation, try a newsgroup
specific to your operating system.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #4
mimmo <-w*********@libero.it> wrote in
news:ZZ**********************@twister2.libero.it:
Hi! I should convert the accented letters of a string in the
correspondent letters not accented. But when I compile with -Wall it
give me:

warning: multi-character character constant

Do the problem is the charset? How I can avoid this warning? But the
worst thing isn't the warning, but that the program doesn't work! The
program execute all other operations well, but it don't print the
converted letters: for example, in the string "licia colò" (with
finally o accented), instead giving in stdout "licia colo" (without
finally o accented), how should be, print "licia col ", with two
spaces. The code is this:


You're using a multi-byte character set, possibly UTF-8. The accented
characters are occupying more than a single char each. See if you have
library functions for dealing with UTF-8 characters and rethink your
algorithm. (you can't scan one char at a time, you need to go by code
point)

The warning is because you are putting more than a single char between the
''s. The interpretation of this depends on endianness. Worse yet, since
the resulting constant won't fit in a single char, you'll never properly
match the input character.

String processing is a real pain...

-josh
Nov 14 '05 #5

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

Similar topics

5
18784
by: Rob | last post by:
Hello all, If I have the following code fragment: /* comment bla bla */ ....code... With a regular expression, how do I get/extract the comment inside this multi line comment block. With...
0
1425
by: access03 | last post by:
Hello, this is my question -- I need to create a multi-page report. each page is about a product selected during runtime. the number of products is also decided at runtime. right now, i...
4
26507
by: Grumble | last post by:
Hello, Is it not legal in C90 to initialize a multi-dimensional array with a one-dimensional initializer as done below? int a = { 1, 2, 3, 4, 5, 6, 7, 8 }; My compiler complains:...
4
2234
by: Richard Hayden | last post by:
Hi, Why does gcc (3.3.2) give me a 'initialization from incompatible pointer type' warning when compiling: int main(int argc, char** argv) { int testa; int** testp = testa; }
11
4431
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
3
2529
by: Eric Laberge | last post by:
Aloha! I've been reading the standard (May '05 draft, actually) and stumbled across this: 6.7.1 Initialization §20 "If the aggregate or union contains elements or members that are aggregates...
6
1866
by: Bonj | last post by:
Hi I have a project that consists of an unmanaged DLL (extended stored procedure) and a static library, which I have converted to managed, although it has got one unmanaged function which is...
4
3120
by: chy1013m1 | last post by:
I am slightly confused as to how to reference multi-dimensional array with pointers. I've tried the following code, and I was able to reference 33 as pptr int multi = {{11,27,33}, {12,13,14}};...
2
1708
by: nleahcim | last post by:
Hi - I am working on writing a number of matrix manipulation functions. The most basic one was a printing algorithm - and it shows the problem I'm having. I'm passing it a pointer a mutidimensional...
2
2379
by: Academia | last post by:
I find the following warning in my Error List: Warning 1 Exception has been thrown by the target of an invocation. 0 0 This is a solution with 41 projects and I have no idea which one is...
0
7148
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...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
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...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
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...
0
3230
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...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.