Sign in to follow this  

Wierd: the first character is always different than the original after convertion

Recommended Posts

JohnsonGPS    109
I am using Visual C++ 2008 Express Edition, and I need to convert the text of the TextBox from System::String^ to TCHAR *. I found there was a post at So I copy and paste the routine StringConvT, then modify a little bit to fit into my program. See the codes at the bottom. Here is my one line of codes to call the conversion. However, after convertion, the first character was always changed to a greek-like character ξ. For example, "C:\Test\Test.txt" to "ξ:\Test\Test.txt". TCHAR * sFN = StringConvT(this->textBoxFile->Text) ; I debugged the software, and found the path was normal even before it was returned. At line "return szUnicode;", szUnicode looked right. However, right after it was sent to sFN, I found the first character became wierd. Does anybody know what happened? Is there anything related to my computer? I recently switched from XP to Vista. Thank you! Here are the codes that I borrowed from the website.
  #ifdef _UNICODE
    #define StringConvT StringConvW
    #define StringConvT StringConvA

  struct StringConvA
    char *szAnsi;
    StringConvA(System::String ^s):


    operator char*() const
      return szAnsi;

  struct StringConvW
    wchar_t *szUnicode;
    StringConvW(System::String^ s):


    operator wchar_t*() const
      return szUnicode;

[edit] Added source tags - Apoch [Edited by - ApochPiQ on May 1, 2009 3:47:24 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this