Looks Like you are not Registered with our Site or Not Logged in. Click Here to Register

It shows that you are unregistered. Please register with us by clicking Here


Go Back   DesiPad.Com :: Simply the Best > IT Cafe > IT Discussion > Tutorials
Connect with Facebook

Notices

Tutorials Step by step instructions with screen shots on how to perform different computing tasks.

Help Contribute to DesiPad.Com
Your Donation Will Be Used To Pay For our ever increasing bandwidth costs, our hosting Service, domain registration, software licensing fees, and maintenance costs
We have received a total of $0 in donations towards our goal of $200
0% of our goal has been reached
Reply  Post New Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-2008
sammer's Avatar
VIP Member
Points: 25,040, Level: 22 Points: 25,040, Level: 22 Points: 25,040, Level: 22
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2007
Location: USA
Gender: Male
Posts: 1,570
DesiPad-Buck: 800.00
Rep Power: 13
sammer is a splendid one to beholdsammer is a splendid one to beholdsammer is a splendid one to beholdsammer is a splendid one to beholdsammer is a splendid one to beholdsammer is a splendid one to beholdsammer is a splendid one to behold
Send a message via MSN to sammer Send a message via Yahoo to sammer
Thumbs up Hole In Notepad

1. Open Notepad
2. Type the text "this app can break" (without quotes)
3. Save the file
4. Re-open the file in Notepad

Notepad displays seemingly-random Chinese characters, or boxes if your default Notepad font doesn't support those characters.

It's not an Easter egg (even though it seems like a funny one), and as it turns out, Notepad writes the file correctly. It's only when Notepad reads the file back in that it seems to lose its mind.

But we can't even blame Notepad: it's a limitation of Windows itself, specifically the Windows function that Notepad uses to figure out if a text file is Unicode or not.

You see, text files containing Unicode (more correctly, UTF-16-encoded Unicode) are supposed to start with a "Byte-Order Mark" (BOM), which is a two-byte flag that tells a reader how the following UTF-16 data is encoded. Given that these two bytes are exceedingly unlikely to occur at the beginning of an ASCII text file, it's commonly used to tell whether a text file is encoded in UTF-16.

But plenty of applications don't bother writing this marker at the beginning of a UTF-16-encoded file. So what's an app like Notepad to do?

Windows helpfully provides a function called IsTextUnicode()--you pass it some data, and it tells you whether it's UTF-16-encoded or not.

Sorta.

It actually runs a couple of heuristics over the first 256 bytes of the data and provides its best guess. As it turns out, these tests aren't terribly reliable for very short ASCII strings that contain an even number of lower-case letters, like "this app can break", or more appropriately, "this api can break".

The documentation for IsTextUnicode says:

These tests are not foolproof. The statistical tests assume certain amounts of variation between low and high bytes in a string, and some ASCII strings can slip through. For example, if lpBuffer points to the ASCII string 0x41, 0x0A, 0x0D, 0x1D (A\n\r^Z), the string passes the IS_TEXT_UNICODE_STATISTICS test, though failure would be preferable.
  #2 (permalink)  
Old 06-26-2008
The DON's Avatar
DON is here - Super Mod.
Points: 21,441, Level: 20 Points: 21,441, Level: 20 Points: 21,441, Level: 20
Activity: 40% Activity: 40% Activity: 40%
 
Join Date: Jan 2007
Gender: Male
Posts: 2,364
DesiPad-Buck: 590.00
Rep Power: 24
The DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant futureThe DON has a brilliant future
Re: Hole In Notepad

pretty awesum, actually any string with the following sequence will result in the same thing:

<first word is of 4 letters>
<second word is of 3 letters>
<third word is of 3 letters>
<fourth word is of 5 letters>

and voila.....
Reply

Tags
hole, notepad

Thread Tools
Display Modes

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 On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Speed Up Ur Acrobat Reader (almost Like Notepad) sammer Tutorials 2 11-01-2007 11:04 PM
Belize Blue Hole rickygunit Image Gallery 2 08-07-2007 05:50 AM


Credit Cards Mortgage Free Advertising Loans Mortgages


Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
eXTReMe Tracker