Sathya Raghunathan wrote:
> Hi
> 
> My application running in Linux connects to informix database and fetches
> data from a TEXT column. The column content has some extended characters.
> For ex: XXX³X and AAA’A. The two characters ³ and ’ have code  179 and 146
> (decimal) which i found by printing in the code as well as from the website.
> 
> Please refer to the below line for the number and character code against
> them. http://www.tony-franks.co.uk/UTF-8.htm
> 
> LANG and LC_CTYPE env variables for my terminal session are set as follows.
> LANG=en_US.UTF-8 and LC_CTYPE=en_US.UTF-8
> 
> My issue is:
> When i print 146 using %c , instead of getting the expected ’ character i
> get only null character but character for 179 is printed properly and when i
> send both characters to file and do a cat of that file, the character for
> 179 is displayed properly. But when i do a vi of that file name, it is
> showing some junk.
> 
> Here is the program.
> #include<stdio.h>
> #include<wchar.h>
> #include<locale.h>
> 
> int main()
> {
> FILE *fp=NULL;
> fp=fopen("myfile.txt","w+");
> setlocale(LC_CTYPE,"en_US.UTF-8");
> unsigned char x=179;
> unsigned char y=146;
> printf("%c %d \n", x,x);
> printf("%c %d \n", y,y);
> fputc(x,fp);
> fputc(y,fp);

fclose(fp);

> return 0;
> }
> 
> Output:
> $./a.out
> ³ 179 ---> this is correct
> 146 ---> Unfortunately this is null character (not even a space)
> 
> $cat myfile.txt
> ³
> 
> Cat displays properly
> But vi myfile.txt shows, ³<92>
> 
> Can you let me know what is the issue? why vi is not showing properly. I am
> not able migrate this data into a table in oracle also.
> should i use iconv? If so how to use it.
> 
> when i say file myfile.txt
> myfile.txt: Non-ISO extended-ASCII text, with no line terminators
> 
> 
> Kindly help.
> 
> Thanks,
> Sathya

Open it up in a hex editor or hex dump it.  vi isn't going to tell you 
anything about the binary data you have output if it being displayed 
incorrectly.  146 decimal is 92 in hex.  Which I would wager is invalid 
UTF-8 (1-byte UTF-8 code points are U+0000 to U+007F).

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/



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

To unsubscribe, send a blank message to 
<mailto:[email protected]>.Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[email protected] 
    mailto:[email protected]

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to