diff -r 675a964f4eb5 -r 35751d3474b7 securityanddataprivacytools/securitytools/certapp/utils/utils.cpp --- a/securityanddataprivacytools/securitytools/certapp/utils/utils.cpp Tue Jul 21 01:04:32 2009 +0100 +++ b/securityanddataprivacytools/securitytools/certapp/utils/utils.cpp Thu Sep 10 14:01:51 2009 +0300 @@ -1,176 +1,176 @@ -/* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of the License "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#include -#include "utils.h" -#include "logger.h" - -#ifndef __LINUX__ -#include -#endif - -typedef unsigned char TUint8; -typedef unsigned int TUint; - -#ifdef __LINUX__ -void OpenUtf8FStreamForRead(std::fstream &aFStream, const char *aUtf8FileName) -{ - aFStream.open(aUtf8FileName, std::ios_base::binary | std::ios_base::in); -} - -void OpenUtf8FStreamForWrite(std::fstream &aFStream, const char *aUtf8FileName) -{ - aFStream.open(aUtf8FileName, std::ios_base::binary | std::ios_base::trunc | std::ios_base::out); -} - -#else - -WCHAR *WindowsUtf8ToUtf16(const char *aUtf8) -{ - int utf8Len = strlen(aUtf8) + 1; // We want to copy the terminator to the new string - int utf16Space = MultiByteToWideChar(CP_UTF8, 0, aUtf8, utf8Len, 0, 0); - if(utf16Space <= 0) - { - dbg << Log::Indent() << "Failed to convert UTF-8 '" << aUtf8 << "' to UTF16" << Log::Endl(); - FatalError(); - return 0; - } - // prog << Log::Indent() << "utf16Space " << utf16Space << Log::Endl(); - WCHAR *utf16 = new WCHAR[utf16Space]; - (void) MultiByteToWideChar(CP_UTF8, 0, aUtf8, utf8Len, utf16, utf16Space); -#if 0 - prog << Log::Indent() << "Raw UTF16 name is (chars " << utf16Space << ")" << Log::Endl(); - for(int i=0; i +#include "utils.h" +#include "logger.h" + +#ifndef __LINUX__ +#include +#endif + +typedef unsigned char TUint8; +typedef unsigned int TUint; + +#ifdef __LINUX__ +void OpenUtf8FStreamForRead(std::fstream &aFStream, const char *aUtf8FileName) +{ + aFStream.open(aUtf8FileName, std::ios_base::binary | std::ios_base::in); +} + +void OpenUtf8FStreamForWrite(std::fstream &aFStream, const char *aUtf8FileName) +{ + aFStream.open(aUtf8FileName, std::ios_base::binary | std::ios_base::trunc | std::ios_base::out); +} + +#else + +WCHAR *WindowsUtf8ToUtf16(const char *aUtf8) +{ + int utf8Len = strlen(aUtf8) + 1; // We want to copy the terminator to the new string + int utf16Space = MultiByteToWideChar(CP_UTF8, 0, aUtf8, utf8Len, 0, 0); + if(utf16Space <= 0) + { + dbg << Log::Indent() << "Failed to convert UTF-8 '" << aUtf8 << "' to UTF16" << Log::Endl(); + FatalError(); + return 0; + } + // prog << Log::Indent() << "utf16Space " << utf16Space << Log::Endl(); + WCHAR *utf16 = new WCHAR[utf16Space]; + (void) MultiByteToWideChar(CP_UTF8, 0, aUtf8, utf8Len, utf16, utf16Space); +#if 0 + prog << Log::Indent() << "Raw UTF16 name is (chars " << utf16Space << ")" << Log::Endl(); + for(int i=0; i