[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Binary versus Text

  • From: David Lee <dlee@calldei.com>
  • To: Jeremy <jhgriffith@gmail.com>, "xml-dev@l..."<xml-dev@l...>
  • Date: Sun, 24 Nov 2013 19:17:44 +0000

RE:  Binary versus Text

> 

>Yet Notepad could read these "Text Files" just fine.

 

Of course it can, because there is no such problem.  

-----------

 

 

The problem is not with UTF8.

The problem is with the Windows "text mode" option to the posix emulated File open methods, such as fopen(), _open() etc.

This mode tries to help people write "posix compatible" code by filtering out window-isms and turning them into unix-isms.

One nice thing this does is convert CF/LF to LF .. .(oh  so HARD ...)(

One *horrid* thing it does is assume you're running like a DOS 1.0 filesystem where Control-Z was actually used as EOF

so when read() if used with this "text mode" in windows encounters a control-Z it returns -1 ... EOF.

 

When the filesystem upgraded some decades ago ( I dont know when exactly .... ) but by then there was a convention to actually

write Control-Z literally to text files to indicate the end of file.    Then there was a transient period where the filesystem itself didnt care about the control-z

but many text oriented programs started looking for control-Z and assuming it was EOF.

This made it into the CRT library for windows for posix compatibility and exists today ...

 

And so yes, if you try to read a UTF8 encoded "Text File" using windows "Text Mode" in the posix emulated system calls

you will not be able to read a Control-Z or any characters after it.

 

-David

 

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

David A. Lee

dlee@calldei.com

http://www.xmlsh.org

 

 

 



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.