diff --git a/profile/src/nsProfile.cpp b/profile/src/nsProfile.cpp index 67b59a885e6b..39c7baaa1ce2 100644 --- a/profile/src/nsProfile.cpp +++ b/profile/src/nsProfile.cpp @@ -774,7 +774,16 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs, { if (cmdResult) { foundProfileCommandArg = PR_TRUE; - nsAutoString currProfileName; currProfileName.AssignWithConversion(cmdResult); + // get a platform charset + nsAutoString charSet; + rv = GetPlatformCharset(charSet); + NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get a platform charset"); + + // convert the profile name to Unicode + nsAutoString currProfileName; + nsCAutoString profileName(strtok(NS_CONST_CAST(char*,(const char*)cmdResult), " ")); + rv = ConvertStringToUnicode(charSet, profileName.get(), currProfileName); + NS_ASSERTION(NS_SUCCEEDED(rv), "failed to convert ProfileName to unicode"); #ifdef DEBUG_profile printf("ProfileName : %s\n", (const char*)cmdResult); @@ -830,7 +839,18 @@ nsProfile::ProcessArgs(nsICmdLineService *cmdLineArgs, #endif foundProfileCommandArg = PR_TRUE; - nsAutoString currProfileName; currProfileName.AssignWithConversion(strtok(NS_CONST_CAST(char*,(const char*)cmdResult), " ")); + + // get a platform charset + nsAutoString charSet; + rv = GetPlatformCharset(charSet); + NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get a platform charset"); + + // convert the profile name to Unicode + nsAutoString currProfileName; + nsCAutoString profileName(strtok(NS_CONST_CAST(char*,(const char*)cmdResult), " ")); + rv = ConvertStringToUnicode(charSet, profileName.get(), currProfileName); + NS_ASSERTION(NS_SUCCEEDED(rv), "failed to convert ProfileName to unicode"); + nsAutoString currProfileDirString; currProfileDirString.AssignWithConversion(strtok(NULL, " ")); if (!currProfileDirString.IsEmpty()) { diff --git a/profile/src/nsProfile.h b/profile/src/nsProfile.h index ad71cc7bb09f..3f37d3933078 100644 --- a/profile/src/nsProfile.h +++ b/profile/src/nsProfile.h @@ -113,3 +113,6 @@ public: nsresult ShowProfileWizard(void); }; +extern nsresult ConvertStringToUnicode(nsString& aCharset, const char* inString, nsAWritableString& outString); +extern nsresult GetPlatformCharset(nsString& aCharset); + diff --git a/profile/src/nsProfileAccess.cpp b/profile/src/nsProfileAccess.cpp index 171c6eea9724..e83539f15c3e 100644 --- a/profile/src/nsProfileAccess.cpp +++ b/profile/src/nsProfileAccess.cpp @@ -114,9 +114,8 @@ nsProfileAccess::~nsProfileAccess() } // A wrapper function to call the interface to get a platform file charset. -static nsresult -GetPlatformCharset(nsAutoString& aCharset) +GetPlatformCharset(nsString& aCharset) { nsresult rv; @@ -132,9 +131,8 @@ GetPlatformCharset(nsAutoString& aCharset) } // Apply a charset conversion from the given charset to Unicode for input C string. -static nsresult -ConvertStringToUnicode(nsAutoString& aCharset, const char* inString, nsAutoString& outString) +ConvertStringToUnicode(nsString& aCharset, const char* inString, nsAWritableString& outString) { nsresult rv; // convert result to unicode