| Index: chrome/browser/sync/util/character_set_converters_win.cc
|
| ===================================================================
|
| --- chrome/browser/sync/util/character_set_converters_win.cc (revision 30948)
|
| +++ chrome/browser/sync/util/character_set_converters_win.cc (working copy)
|
| @@ -2,61 +2,19 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/utf_string_conversions.h"
|
| #include "chrome/browser/sync/util/character_set_converters.h"
|
|
|
| -#include <windows.h>
|
| -
|
| -#include <string>
|
| -
|
| -using std::string;
|
| -
|
| namespace browser_sync {
|
|
|
| -// Converts input_string to UTF8 and appends the result into to output_string.
|
| -void AppendPathStringToUTF8(const PathChar* wide, int size,
|
| - string* output_string) {
|
| - CHECK(output_string);
|
| - if (0 == size)
|
| - return;
|
| -
|
| - int needed_space = ::WideCharToMultiByte(CP_UTF8, 0, wide, size, 0, 0, 0, 0);
|
| - // TODO(sync): This should flag an error when we move to an api that can let
|
| - // utf-16 -> utf-8 fail.
|
| - CHECK(0 != needed_space);
|
| - string::size_type current_size = output_string->size();
|
| - output_string->resize(current_size + needed_space);
|
| - CHECK(0 != ::WideCharToMultiByte(CP_UTF8, 0, wide, size,
|
| - &(*output_string)[current_size], needed_space, 0, 0));
|
| +// Returns UTF8 string from the given FilePath.
|
| +std::string FilePathToUTF8(const FilePath& file_path) {
|
| + return WideToUTF8(file_path.value());
|
| }
|
|
|
| -bool AppendUTF8ToPathString(const char* utf8, size_t size,
|
| - PathString* output_string) {
|
| - CHECK(output_string);
|
| - if (0 == size)
|
| - return true;
|
| - // TODO(sync): Do we want to force precomposed characters here?
|
| - int needed_wide_chars = ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
|
| - utf8, size, 0, 0);
|
| - if (0 == needed_wide_chars) {
|
| - DWORD err = ::GetLastError();
|
| - if (MB_ERR_INVALID_CHARS == err)
|
| - return false;
|
| - CHECK(0 == err);
|
| - }
|
| - PathString::size_type current_length = output_string->size();
|
| - output_string->resize(current_length + needed_wide_chars);
|
| - CHECK(0 != ::MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8, size,
|
| - &(*output_string)[current_length], needed_wide_chars));
|
| - return true;
|
| +// Returns FilePath from the given UTF8 string.
|
| +FilePath UTF8ToFilePath(const std::string& utf8) {
|
| + return FilePath(UTF8ToWide(utf8));
|
| }
|
|
|
| -void TrimPathStringToValidCharacter(PathString* string) {
|
| - CHECK(string);
|
| - // Constants from http://en.wikipedia.org/wiki/UTF-16
|
| - if (string->empty())
|
| - return;
|
| - if (0x0dc00 == (string->at(string->length() - 1) & 0x0fc00))
|
| - string->resize(string->length() - 1);
|
| -}
|
| -
|
| } // namespace browser_sync
|
|
|