473,802 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code in ASCII UTF8??

I know in ASCII '\r' is 0x0d,'\n' is 0x0a.
But some say ASCII characters in UTF8 is unchanged.
Now I want to know in UTF8 '\r' and '\n' are already 0x0d and 0x0a??
Could anybody can tell me? Very Thanks!!!!

Nov 14 '05 #1
16 2744
Le jeudi 17 février 2005 à 09:38, chunhui_true a écrit dans
comp.lang.c*:
I know in ASCII '\r' is 0x0d,'\n' is 0x0a.
But some say ASCII characters in UTF8 is unchanged.
Now I want to know in UTF8 '\r' and '\n' are already 0x0d and 0x0a??
Could anybody can tell me? Very Thanks!!!!


That's correct. All ASCII characters (0x00 to 0x7f) are unchanged in
UTF-8. All Unicode values from 0x80 up are encoded into 2, 3, or 4 bytes
that never reuse 0x00 to 0x7f.

--
___________ 17/02/2005 11:21:46
_/ _ \_`_`_`_) Serge PACCALIN -- sp ad mailclub.net
\ \_L_) Il faut donc que les hommes commencent
-'(__) par n'être pas fanatiques pour mériter
_/___(_) la tolérance. -- Voltaire, 1763
Nov 14 '05 #2
On Thu, 17 Feb 2005 00:38:52 -0800, chunhui_true wrote:
I know in ASCII '\r' is 0x0d,'\n' is 0x0a.


Wasn't that the other way around on Macs?

Lawrence
Nov 14 '05 #3
Lawrence Kirby wrote:

On Thu, 17 Feb 2005 00:38:52 -0800, chunhui_true wrote:
I know in ASCII '\r' is 0x0d,'\n' is 0x0a.


Wasn't that the other way around on Macs?


<shrug> depends what you mean by '\r' and '\n'. :-)

On a Mac, a text file's end-of-line indicator (C89 draft 2.1.1.2)
is 0x0D. When this is read into a C program, it is translated into
a '\n' character.

If anyone's got a Mac with a C compiler, could they please tell us
what this program prints on that system?

#include <stdio.h>

int main(void)
{
printf("\\\r = %d\n", '\r');
printf("\\\n = %d\n", '\n');
return 0;
}
Nov 14 '05 #4
infobahn wrote:
....
If anyone's got a Mac with a C compiler, could they please tell us
what this program prints on that system?

#include <stdio.h>

int main(void)
{
printf("\\\r = %d\n", '\r');
printf("\\\n = %d\n", '\n');
return 0;
}


Probably not what you think. ;-)

Jirka
Nov 14 '05 #5
On 2005-02-17 11:52:54 -0500, infobahn <in******@btint ernet.com> said:
include <stdio.h>

int main(void)
{
printf("\\\r = %d\n", '\r');
printf("\\\n = %d\n", '\n');
return 0;
}


ITYM:
#include <stdio.h>

int main(void)
{
printf("\\r = %d\n", '\r');
printf("\\n = %d\n", '\n');
return 0;
}
Which outputs:
\r = 13
\n = 10

--
Clark S. Cox, III
cl*******@gmail .com

Nov 14 '05 #6
On 2005-02-17 11:57:51 -0500, Lawrence Kirby <lk****@netacti ve.co.uk> said:
On Thu, 17 Feb 2005 00:38:52 -0800, chunhui_true wrote:
I know in ASCII '\r' is 0x0d,'\n' is 0x0a.


Wasn't that the other way around on Macs?


No, the actual values of '\r' and '\n' are unchanged on the Mac. The
difference was when reading/writing a file in text mode on a MacOS
before 10. (As of 10, the UNIX convention has been adopted; i.e. text
mode and binary mode are identical).
--
Clark S. Cox, III
cl*******@gmail .com

Nov 14 '05 #7
"Clark S. Cox III" wrote:

On 2005-02-17 11:52:54 -0500, infobahn <in******@btint ernet.com> said:
include <stdio.h>

int main(void)
{
printf("\\\r = %d\n", '\r');
printf("\\\n = %d\n", '\n');
return 0;
}
ITYM:
#include <stdio.h>

int main(void)
{
printf("\\r = %d\n", '\r');
printf("\\n = %d\n", '\n');


\E\r\,\ \y\e\s\,\ \I\ \d\i\d\ \m\e\a\n\ \t\h\a\t\.

Which outputs:
\r = 13
\n = 10


I expected as much, but since I haven't used a Mac since 1989, I
didn't want to risk making an idiot of myself. (Seems I did that
anyway, in a rather unexpected direction.)
Nov 14 '05 #8
infobahn wrote:
Lawrence Kirby wrote:
On Thu, 17 Feb 2005 00:38:52 -0800, chunhui_true wrote:

I know in ASCII '\r' is 0x0d,'\n' is 0x0a.
Wasn't that the other way around on Macs?


<shrug> depends what you mean by '\r' and '\n'. :-)


True, <cr> is 0x0D and <lf> is 0x0A would be better description.
On a Mac, a text file's end-of-line indicator (C89 draft 2.1.1.2)
is 0x0D. When this is read into a C program, it is translated into
a '\n' character.

If anyone's got a Mac with a C compiler, could they please tell us
what this program prints on that system?

#include <stdio.h>

int main(void)
{
printf("\\r = %d\n", '\r'); [corrected]
printf("\\n = %d\n", '\n'); [corrected]
return 0;
}


Metrowerks 3.0, Mac IIvx, swap \n and \r enabled...

\r = 10
\n = 13

The compiler option allows mac implementations to avoid having
to perform runtime translations of text file end-of-lines.

--
Peter

Nov 14 '05 #9
Does ASCII characters remain unchanged under UTF8????Since it
unchanged,Why I can't printf thme in screen?
I use libcap get the FTP commands from Ethernet.I have one class to

get all packages and flowed,buffered them,Then aonther class can
readline (ended with \r\n)from buffer.Every time I readline from buffer

to get a command.
When I use CuteFTP I can get all commands an printf them in
screen.But when I use IE to FTP I can see one command "set utf8 on" and

then next commands I can't printf them in screen.Should I conver utf8
to ASCII?:(

Nov 14 '05 #10

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

Similar topics

17
542
by: DraguVaso | last post by:
Hi, For my SMS-application I need to be able to send characters with accents (like é and à). But this doesn't seem to work in Text Mode, so i will need to do it in PDU Mode. Does anybody has soem converting routines for that in VB.NET? I need my text to be converted to a PDU-message, and back (for received messages). Thansk in advance,
12
13039
by: chunhui_true | last post by:
i have a class, it can read one line(\r\n ended) from string,when i read line from utf8 string i can't get any thing! maybe i should conversion utf8 to ascii??there is any function can conversion utf8 to ascii? very thanks to your help!!
13
6143
by: Dan V. | last post by:
How do I create a one line text file with these control codes? e.g.: 144 = 0x90 and 147 = 0x93? I am trying to create a one line text file with these characters all one one row with no spaces. 1. 144 = 0x90 2. 147 = 0x93 3. STX = (^B = 2 = 0x2) 4. NUL = (^@ = 0 = 0x0)
6
7163
by: Friso Wiskerke | last post by:
Hi all, I'm creating a fixed length textfile with data which is sent out to a third-party which in turn reads the file and processes it. Some of the characters are not part of the lower ASCII table. This causes problems because an È (&HC4) in the textfile is converted into 2 bytes on the receiving end which then in turn shifts the remaining data on the line one byte to the right... and in a fixed length textfile that's a disaster Is...
1
12716
by: Hooyoo | last post by:
I read the content from a file encoded with UTF8 like this: byte data = binaryReader.ReadBytes(file.Length); And next step, I want to transform data to ASCII format, How can I do this? You know, Using Encoding.UTF8.GetString(data) can get a ASCII string, but I need a byte. I hope you get my point. Any suggestion will be appreciated.
10
3001
by: silverburgh.meryl | last post by:
Hi, Is there a string function to trim all non-ascii characters out of a string? Let say I have a string in python (which is utf8 encoded), is there a python function which I can convert that to a string which composed of only ascii characters? Thank you.
13
3908
by: =?Utf-8?B?YXVsZGg=?= | last post by:
i have come across a situation in my project where i read a text file with some characters greater than hex 0x7f. i need to write character (0xE0) to a new file as an exception. however when i attempt to write this via "Console.Write" or "filestream.Write" it seems the value changes. most of the output file is in text mode. if i view the original file in binary mode i see the character i'm having issue with as "e0 00" but when i...
5
3462
by: aagarwal8 | last post by:
Hi, I want to display the extended ASCII charset in the list view (in List mode), but when i assign any of the Ex. ASCII chars to the listview item text, it renders blank. Any idea how i can display the Ex ASCII chars in list view. Regards, Ankit!!
3
3202
by: kettle | last post by:
Hi, I was wondering how I ought to be handling character range translations in python. What I want to do is translate fullwidth numbers and roman alphabet characters into their halfwidth ascii equivalents. In perl I can do this pretty easily with tr: tr/\x{ff00}-\x{ff5e}/\x{0020}-\x{007e}/;
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10538
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10305
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9115
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.