Archive

Archive for the ‘Programming’ Category

OpenStreamOnFile Does Not Support Unicode?

February 28th, 2008 gorshing No comments

I have been working on converting .msg file to .eml files and I just couldn’t get anything to work correctly. I was wanting to have my small converter project work with Unicode. All the functions returned as though everything worked correctly, the only problem was that nothing was written out to the eml file.

I googled around and found the following post from Google Groups.

I will be watching the documentation for this function as I left snide remark for MSFT feedback.

I will be posting the converter project which I am using. I have written a C++ DLL to access the MAPI items, and then wrote a small wrapper C# DLL to make it easy for managed developers to use in there projects.

Categories: Programming Tags:

Being a Computer Scientist

January 23rd, 2008 gorshing No comments

At one of my previous places of employment, I made a comment which made numerous of my co-workers very angry at me. I felt as though I was completely justified in saying it, but I soon found out how much I upset them.

I believe I was talking about Bill Joy, I honesty can’t recall off the top of my head who I was talking about, but a co-worker asked who that was. I responded with a rhetorical question in awe that they didn’t know who I was talking about. I rattled off a few other (in my opinion) popular/famous Computer Scientists, as a line of questioning to see if they knew any others … which they did not. FYI, I believe I mentioned Alan Turing, Larry Ellison, Donald Knuth, and Steve Wozniak among others.

I then made a comment which made a few of them mad at me “I don’t understand why somebody being a programmer, a computer scientist, and not knowing the pioneers in our field”. The conversation continued for a short while, but it became readily apparent I was in the minority.

The Senior Lead at that time was Paul Carter, he agreed with me during the whole conversation but I was the one who took all the heat. I have kept in touch with him since leaving and received an email from him just the other day.

His email had a link to a blog post about Donald Knuth, and thought about that conversation. I am glad to see someone else who has a very similar stand as I do:

If you don't know who Knuth is, then you're not a programmer. If you're a programmer and you don't know who Knuth is, well... I have no idea what rock you've been hiding under, but you should probably be fired.
Categories: Programming Tags:

PHP Equality and Identity Operators

January 1st, 2008 gorshing No comments

I am working on learning the Zend Framework, and along with that PHP as well (of course). I stumbled upon a code snippet on the internet which I didn’t realize would work. I have seen the use of the identify operator in PHP before but I soon realized I didn’t know all that I should. So I dived into this topic a little bit more and soon found out that more seasoned PHP programmers aren’t too fluent in the differences between the two operators and what is (and not) possible.

Most programmers are accustomed to the equality operator as noted by ‘==’. This operator performs a check on the operands and if they are equal (you will soon learn equal has a very broad definition) then it will return true. What I mean by a broad definition is that the PHP interpreter will perform a conversion based upon what the operand contains. In an attempt to keep my examples more simple I will be talking about numerics and strings.

If both operands are a string value, but both contain a numeric expression the interpreter will attempt to convert both expressions to a numeric value then perform the numeric comparison. If one of the operands is a numeric value and you compare it to a string type, the string is converted to a numeric value as well. If the string conversion fails, then a 0 is returned. As an example, if you run the following code, it will print out ’1′.

<?php
  // This prints 1
  print ("000" == "0" && "0" == 0 && 0 == "cat");
?>

The following will result in a string comparison instead of a numeric comparison. The PHP interpreter recognizes “0″ as a numeric expression, but since “cat” is not a numeric expression then they are both left alone and compared as strings.

<?php
  // Does nothing
  print ("0" == "cat");
?>

If you are more comfortable with a strongly typed language such as Java or C++ then the identity operator is going to be what you would be more accustomed to. In PHP this is denoted as ‘===’, this performs tests as you are more familiar with. The identity operator will return true if both operands are equal and of the same type. The above two examples, if used with the identity operator would return false in all cases.

In the following example since $a is not of a valid numeric expression no conversion takes place and a string comparison is performed. Conversely $c is a valid numeric expression (see Scientific Notation) this is converted and evaluated.

<?php
  $a = "0f0"; // This is not hex, as it does not start with 0x, ex. "0xf0"
  $b = "000";
 
  // This fails
  print ($a == $b); // "0f0" == "000"
 
  $c = "0e0";
 
  // This is successful
  print ($c == $b); // "0e0" == "000"
?>

Just one more last example, here both variables are valid numeric expressions. They both evaluate to 0 using the scientific notation.

<?php
  $a = "0e2";
  $b = "0e3";
 
  // This is successful
  print ($a == $b);
?>

I hope this has shed some light on the subject. The following are some references which helped me understand this a little better.

BlueShoes PHP Syntax Exam

PHP Docs for Comparison Operators – And a comment which started me on this journey

Categories: PHP Tags:

Why the limitation on build numbers

January 13th, 2007 gorshing Comments off

The other day I posted on the limitation on build numbers. Well Neil Enns has delved into this topic a little bit more, and I wanted to post about it as well … Why are build numbers limited to 65535.

Categories: Programming Tags:

The version specified is not in the normal format

January 12th, 2007 gorshing Comments off

I usually pride myself in figuring out any problems I may have while developing. Well one popped up the other day on me and I couldn’t figure out why, well I just changed a couple numbers just to get the build working again and continued on. I had many things to get done and I wanted to come back to this problem when I had more time.

Well the time just passed on by and I actually forgot all about it. Well today I just happened to stumble across a post by Frans Bouma. Just wanted to say thank you Frans for the post. I would never have thought about 16 bits numbers.

Categories: Programming Tags:

C# Explicit Casts

September 29th, 2006 gorshing Comments off

Most programmers know how to use an explicit cast. In C# the way of handling is as follows:

int i = 0;

decimal d = 3.4M;

i = (int)d;

This is a trivial case and my main point is how will the explicit casting operation handle null references.

When attempting to cast a null reference to another reference type, the casting will not throw an exception. So be careful after attempting to access a method or property from a reference after casting, it is a possibility the reference is set to null. I (try to) always check for a null reference before attempting to cast in hoping I will save some CPU cycles.

Categories: Programming Tags: