472,958 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 17708
"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
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
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
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
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
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
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.