Attention: We are retiring the ASP.NET Community Blogs. Learn more >

David Cumps

#region .Net Blog

  • Notepad bug? Encoding issue?

    Someone showed me a weird text file today. It was a bat file with 'copy MeYou.bak MeYou.txt'. When you would ran it, it would work. But when you opened it in Notepad, there was nothing.

    So we decided to look a bit into this and here is something we came up with to 'create' invisible text:

    Open notepad and enter:
    ' abc.bak abc.txt'

    (That is: space abc dot bak space abc dot txt, no line break, without the quotes)

    It doesn't work with every string, just follow us on this example and use that one.

    Save your file. Notepad picks default ANSI as encoding.

    Open your file, Notepad seems to open by default in Unicode encoding.

    Your text is now invisible.



    Does anyone know why the saving default is different from the opening default?

    And why does it happen to that particular piece of text. It doesnt happen to ' b.b b.b' or ' .bak .txt'.

    It looks the same when viewing it through a hex editor. But apparently it has to do something with encoding.

    Anyone who can explain?

    Update: When you paste it in IE or Trillian you get '????????', like some people tried in the comments ;)

    Update2: In my notepad screenshot the font was Terminal, when I choose Verdana it are indeed squares. Not that invisible anymore, but still wrong :)

    Update3: You can find an explanation on why this is happening at The Old New Thing.

  • C#-Script

    I was playing around with the thought of being able to figure out some other possibilities for C#.

    One thing I came up with was, why not make a possibility to quickly write something small in C# and run it. I'm talking really really really small here.

    So I decided to write an article about it, maybe someone thinks of something and extends it. Before you tell me it's useless, let me say this is only something done to try out new things and to get ideas.

    Here is my version of C#-Script ;)

    One frustrating thing that keeps bothering me is. In code i specifically said to not create an executable, and what happens? It creates an executable. Anyone an idea of why it's doing this? Doesn't 'InMemory' mean in RAM, without files on your HD?

    Hope you like it :)

  • Non-Rectangular Forms - C#

    I added another article in the 'Basic C# Examples'-series. ;)

    It should answer the question of how to make nonsquare windows?

    There is another example out there (which I can't find the link of anymore) that uses pointers to run over the image. Because of performance issues. So, I decided to take the GetPixel approach and see if it worked. And it does ;) Don't notice any performance hit here thou, maybe on weaker computers..

    How To Make Non-Rectangular Forms.