Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > non ascii chracter problem

Reply
Thread Tools

non ascii chracter problem

 
 
Burak
Guest
Posts: n/a
 
      10-25-2007
i'll try to explain my problem shortly...

char wrt[50];
char word[50];

strcpy(wrt,"şç");
printf("%s\n",wrt);
//i get * as output

gets(word); //i will write şç
printf("%s \n",word);
//output of this is correct,şç

How can i solve this?
Any suggestions?

 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      10-25-2007
Burak wrote:
>
> i'll try to explain my problem shortly...
>
> char wrt[50];
> char word[50];
>
> strcpy(wrt,"şç");
> printf("%s\n",wrt);
> //i get  as output
>
> gets(word); //i will write şç
> printf("%s \n",word);
> //output of this is correct,şç
>
> How can i solve this?
> Any suggestions?


Never, ever, under any circumstances, use gets(). You can get a
replacement (with equal convenience that can be used safely) in
ggets(). You will find it at:

<http://cbfalconer.home.att.net/download/>

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>



--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
 
 
 
Richard
Guest
Posts: n/a
 
      10-25-2007
CBFalconer <(E-Mail Removed)> writes:

> Burak wrote:
>>
>> i'll try to explain my problem shortly...
>>
>> char wrt[50];
>> char word[50];
>>
>> strcpy(wrt,"şç");
>> printf("%s\n",wrt);
>> //i get ■ as output
>>
>> gets(word); //i will write şç
>> printf("%s \n",word);
>> //output of this is correct,şç
>>
>> How can i solve this?
>> Any suggestions?

>
> Never, ever, under any circumstances, use gets(). You can get a
> replacement (with equal convenience that can be used safely) in
> ggets(). You will find it at:
>
> <http://cbfalconer.home.att.net/download/>
>
> --
> Chuck F (cbfalconer at maineline dot net)
> Available for consulting/temporary embedded and systems.
> <http://cbfalconer.home.att.net>


gets can be and is used perfectly safely in many controlled
situations. Advisable to use it? Probably not. ggets has its own issues
IMO.
 
Reply With Quote
 
Keith Willis
Guest
Posts: n/a
 
      10-25-2007
On Thu, 25 Oct 2007 16:56:10 +0200, Richard <(E-Mail Removed)> wrote:

>CBFalconer <(E-Mail Removed)> writes:
>
>> Never, ever, under any circumstances, use gets(). You can get a
>> replacement (with equal convenience that can be used safely) in
>> ggets(). You will find it at:
>>

>gets can be and is used perfectly safely in many controlled
>situations. Advisable to use it? Probably not. ggets has its own issues
>IMO.


I'm puzzled.
1. How could gets be used "perfectly safely"?
2. What on earth is wrong with fgets()? [f]ggets makes me free memory
that it allocated, whereas with fgets, I can sort out my own
allocation as and when (and however) I want to.
--
PGP key ID 0xEB7180EC
 
Reply With Quote
 
santosh
Guest
Posts: n/a
 
      10-25-2007
Keith Willis wrote:

> On Thu, 25 Oct 2007 16:56:10 +0200, Richard <(E-Mail Removed)> wrote:
>
>>CBFalconer <(E-Mail Removed)> writes:
>>
>>> Never, ever, under any circumstances, use gets(). You can get a
>>> replacement (with equal convenience that can be used safely) in
>>> ggets(). You will find it at:
>>>

>>gets can be and is used perfectly safely in many controlled
>>situations. Advisable to use it? Probably not. ggets has its own
>>issues IMO.

>
> I'm puzzled.
> 1. How could gets be used "perfectly safely"?


If you can completely control stdin.

<snip>

 
Reply With Quote
 
Richard
Guest
Posts: n/a
 
      10-25-2007
Keith Willis <(E-Mail Removed)> writes:

> On Thu, 25 Oct 2007 16:56:10 +0200, Richard <(E-Mail Removed)> wrote:
>
>>CBFalconer <(E-Mail Removed)> writes:
>>
>>> Never, ever, under any circumstances, use gets(). You can get a
>>> replacement (with equal convenience that can be used safely) in
>>> ggets(). You will find it at:
>>>

>>gets can be and is used perfectly safely in many controlled
>>situations. Advisable to use it? Probably not. ggets has its own issues
>>IMO.

>
> I'm puzzled.
> 1. How could gets be used "perfectly safely"?


if you know the problems with it in a badly controlled environment then
it doesn't take a leap of faith to figure out how it can be used safely
- when you totally control the input stream e.g another process.

> 2. What on earth is wrong with fgets()? [f]ggets makes me free memory
> that it allocated, whereas with fgets, I can sort out my own
> allocation as and when (and however) I want to.


Nothing is wrong with fgets. Did anyone say there is?

 
Reply With Quote
 
Ben Bacarisse
Guest
Posts: n/a
 
      10-25-2007
Burak <(E-Mail Removed)> writes:

> i'll try to explain my problem shortly...
>
> char wrt[50];
> char word[50];
>
> strcpy(wrt,"şç");
> printf("%s\n",wrt);
> //i get * as output
>
> gets(word); //i will write şç
> printf("%s \n",word);
> //output of this is correct,şç
>
> How can i solve this?


These things are very hard to debug over Usenet. I can not be sure of
what you have in your C file or in your output since simply copying
into a message can change the character encoding.

> Any suggestions?


Best guess: the program you use to type in your C code uses a
different character encoding from the terminal/console you run it on.
To get a better-informed guess, ask in a group that knows about your
development environment.

--
Ben.
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      10-25-2007
Keith Willis wrote:
> Richard <(E-Mail Removed)> wrote:
>> CBFalconer <(E-Mail Removed)> writes:
>>
>>> Never, ever, under any circumstances, use gets(). You can get a
>>> replacement (with equal convenience that can be used safely) in
>>> ggets(). You will find it at:

>>
>> gets can be and is used perfectly safely in many controlled
>> situations. Advisable to use it? Probably not. ggets has its own
>> issues IMO.

>
> I'm puzzled.
> 1. How could gets be used "perfectly safely"?
> 2. What on earth is wrong with fgets()? [f]ggets makes me free
> memory that it allocated, whereas with fgets, I can sort out
> my own allocation as and when (and however) I want to.


I did NOT say gets can be used safely. I recommended ggets. Note
the extra g. There is nothing wrong with fgets if you can put up
with its nuisances, such as not knowing whether the line is
complete without checking for a terminal '\n'. In many cases the
first thing you are going to do with an incoming line is allocate
memory to hold it, and tuck it away. No need with ggets.

A routine is only useful if it fits your practice. The ggets
package includes usage examples.

Incidentally, "Richard <(E-Mail Removed)>" is plonked here, because
his recommendations are generally idiotic. This includes his
quoted advice above.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


--
Posted via a free Usenet account from http://www.teranews.com

 
Reply With Quote
 
Richard Bos
Guest
Posts: n/a
 
      10-26-2007
Richard <(E-Mail Removed)> wrote:

> CBFalconer <(E-Mail Removed)> writes:
>
> > Burak wrote:


> >> gets(word); //i will write şç


> > Never, ever, under any circumstances, use gets(). You can get a
> > replacement (with equal convenience that can be used safely) in
> > ggets(). You will find it at:


> gets can be and is used perfectly safely in many controlled situations.


Not legally in states where bondage gear falls under the local obscenity
laws.

Richard
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DBD::Oracle, Unicode, non-UTF8-non-ASCII strings Jochen Lehmeier Perl Misc 0 07-23-2009 06:02 PM
Regex with ASCII and non-ASCII chars TOXiC Python 5 01-31-2007 04:48 PM
[FR/EN] how to convert the characters ASCII(0-255) to ASCII(0-127) Alextophi Perl Misc 8 12-30-2005 10:43 AM
routine/module to translate microsoft extended ascii to plain ascii James O'Brien Perl Misc 3 03-05-2004 04:33 PM



Advertisments