Computing.Net > Forums > Solaris > multi-byte characters in C

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

multi-byte characters in C

Reply to Message Icon

Name: Kishore Kotra
Date: November 26, 2002 at 08:11:52 Pacific
OS: Solaris 5.6
CPU/Ram: SPARC
Comment:

Hi,

I'm receiving messages from IBM MQSeries and processing them using C. I'm using a char buffer to store the msgs. But now, I'm receiving multi-byte characters in the msg. How to handle this? Cos I don't know the character set it belongs and moreover my program reads them as two disparate 1 byte characters.

Also,

How to set env variable LANG so that it remains same for the child processes.

Thanks in anticipation

Cheers,
K i s h o r e




Sponsored Link
Ads by Google

Response Number 1
Name: Aakash
Date: November 26, 2002 at 23:21:23 Pacific
Reply:

Kishore! if you could be bit clear with the charsets (type of inputs) would br easier.
little what I can gather, here's it!
use headers
#include
#include
#include
and some routines for multi-byte characters within it...
Check out man pages:
mbtowc(3C), wctomb(3C), isdigit(3C)...

about LANG setting
if using following shell: sh/bash/ksh
# LANG=english
# export LANG
if shell is: csh
# setenv LANG english

above prefers to be before the start of program, if needed to be issued from the program itself and required for the child, then follow up:
#include
main(int argc, char *argv[], char *env[])
{ ...
// here *env[] will help you get the environ, NOT SET.
int ret=0;
char *var;
// generally basics..
ret=putenv("LANG=english");
var=getenv("LANG");
.
// CONFIGURE HERE **environ (global var)
.
// matter comes before the child process..
fork()...
}

you can use the global object 'extern char **environ' in your program to add the environment variable, cause *env has the NULL pointer as the last character.
Routines: execl(),execv(),execvp(), and execlp(), place the pointer to the environ of calling process in the global object and is used to pass the environ of the calling process to the new process.
check man-pages: exec(2)

if the above matter relates locale, LANG="C", then you can use the 'setlocale()' routine for initializing the LANG.
check man-pages: setlocale(3C)

'ex: man -s3c setlocale'

for more informations you can check me

-aakash


0
Reply to Message Icon

Related Posts

See More


Doesn't recognize NIC solaris installation prob...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: multi-byte characters in C

programming in c www.computing.net/answers/solaris/programming-in-c/2136.html

character substitution in c-shell www.computing.net/answers/solaris/character-substitution-in-cshell/3518.html

C programming for serial ports www.computing.net/answers/solaris/c-programming-for-serial-ports/4871.html