Will the real 'PHI' symbol please stand up?
In my last post SolidWorks Hole Size and Extended ASCII codes I had mentioned that I needed to input the 'PHI' symbol when creating a Wizard Simple Hole in SolidWorks using the SolidWorks API for Visual C++.
Well it turns out that while my mind was in the right place, I probably should have taken that left turn at Albuquerque. So lets revisit that topic again. It seems that using Extended ASCII codes for this job was the wrong solution, though it did lead me to find out more about specifying symbols using Unicode, since I figured that I need to specify the PHI symbol using Unicode.
So now the questions are "what is the Unicode character for the PHI symbol?" and "how do we specify that character in C++"?
Lets answer the more difficult of the two questions first, which is what this post is all about.
What is the Unicode character the PHI symbol?
Well turns out that there are numerous ways to express the same symbol (at least they are the same in that they are all called PHI). Here are a few Unicode characters that MS Windows recognizes as PHI symbols:
- U+0278 (http://www.fileformat.info/info/unicode/char/278/index.htm)
- U+03D5 (http://www.fileformat.info/info/unicode/char/3d5/index.htm)
- U+03A6 (http://www.fileformat.info/info/unicode/char/03a6/index.htm)
- U+00D8 (http://www.fileformat.info/info/unicode/char/d8/index.htm)
Surprisingly the answer is similar to specifying Extended ASCII codes. Instead of using a "\x" we simply use a "\u". Here is what it looks like:
CComBSTR size(L"\u00D80.15");Breaking it down:
- The "L" is to specify that this is Unicode.
- The "\u" is to specify Unicode characters in literal strings
- And as we saw as the answer to the first question, the "00D8" (thats ZeroZeroD8) is the PHI symbol
- The trailing 0.15 is simply a size that SolidWorks Hole could have
- BUT unlike Extended ASCII we can specify the non-Unicode portions of the string literal, using regular characters i.e. the "0.15" part.
IF YOU CAN'T SEE THE PHI SYMBOL ITSELF AT THE SPECIFIED LOCATION THEN YOUR BROWSER DOESN'T UNDERSTAND UNICODE CHARACTERS. TO FIX THIS PROBLEM GET A BETTER BROWSER.