Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How to insert Hexadecimal characters

by Marshall (Canon)
on Dec 03, 2009 at 11:47 UTC ( [id://810817]=note: print w/replies, xml ) Need Help??


in reply to How to insert Hexadecimal characters

No! If you are printing text, at least x'0A' (line feed) will be inserted (not x'0D').

The question is whether or not a x'0D' (carriage return) will also be inserted before the x'0A'. If you are interested , I refer you to: http://www.asciitable.com/ for the standard ASCII characters (doesn't cover the wide 16 bit ones).

In ancient days, each line ended with CR,LF,RUBOUT(x'00'). The RUBOUT(NUL) x'00', was needed to keep the fingers on the mechanical tape reader/punch lubricated. Keeping the CR and LF separate allowed pictures to be drawn of a sort. CR (carriage return) just meant go back to the beginning of the line and then more stuff (different characters) could be printed on the same line. I hope you get to see one of these early pictorial masterpieces. I haven't used a printer for a very long time that could reproduce such an image - there isn't any idea that "over-striking" something will make it darker like existed with typewriter ribbon technology.

As far as Perl goes, Perl print in a text context will do the "right thing" for your platform. For some reason Windows kept this CR,LF idea while Unix moved to just LF.

I have often moved files between Unix and Windows systems. In the old days, this was a big hassle and I would have to run some sort of "fixit" script on one machine or the other. Now I just use FireFTP (other modern FTP programs work also) and this automatically adjusts this stuff for me when I am in text mode (and it is very smart about figuring that out).

Perl itself is "smart" about CR/LF. It will ignore this CR if it exists. Perl can read any text file that it created on any platform.

There are some situations, like hashing to disk with fixed record sizes where this line termination stuff matters a lot. But I'm not hearing that is not the case. I've written programs in both Perl and C using this concept and I'd be happy to show you the code, but I don't think that is what you need.

In short: don't worry about this in your Perl programs. If this CR needs to be inserted before the LF, use a std FTP program in text mode to make the transfer between the *NIX and Windows box.

  • Comment on Re: How to insert Hexadecimal characters

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://810817]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-25 21:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found