summaryrefslogtreecommitdiffstats
path: root/base/icu_util.cc
diff options
context:
space:
mode:
authorevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-15 01:04:11 +0000
committerevanm@google.com <evanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-15 01:04:11 +0000
commit4c0040c49331c5cb5b88960ecec04ce8a5f0756a (patch)
treeeb20f932e07a7c3fcb5bf144cba675d48ca791af /base/icu_util.cc
parent1b3deed79fc638d3755ba5159108712238d8beb7 (diff)
downloadchromium_src-4c0040c49331c5cb5b88960ecec04ce8a5f0756a.zip
chromium_src-4c0040c49331c5cb5b88960ecec04ce8a5f0756a.tar.gz
chromium_src-4c0040c49331c5cb5b88960ecec04ce8a5f0756a.tar.bz2
To pass string_util_unittest, we need the ICU data file. To get the ICU data file, we need some of PathService, which brings along with it a bunch of other needed functions. So here are a bunch of stubs, along with another file's worth of passing tests. (Based on a patch from Dean.)
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/icu_util.cc')
-rw-r--r--base/icu_util.cc22
1 files changed, 16 insertions, 6 deletions
diff --git a/base/icu_util.cc b/base/icu_util.cc
index fdb2003..b0f999d 100644
--- a/base/icu_util.cc
+++ b/base/icu_util.cc
@@ -29,7 +29,7 @@
#include "build/build_config.h"
-#ifdef OS_WIN
+#if defined(OS_WIN)
#include <windows.h>
#endif
@@ -40,12 +40,14 @@
#include "base/logging.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/sys_string_conversions.h"
+#include "unicode/putil.h"
#include "unicode/udata.h"
namespace icu_util {
bool Initialize() {
-#ifdef OS_WIN
+#if defined(OS_WIN)
// Assert that we are not called more than once. Even though calling this
// function isn't harmful (ICU can handle it), being called twice probably
// indicates a programming error.
@@ -71,11 +73,19 @@ bool Initialize() {
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
return err == U_ZERO_ERROR;
-#else
- // Windows ships ICU's data separate, so it needs to link the code to data
- // here. Other platforms don't need this.
+#elif defined(OS_MACOSX)
+ // Mac bundles the ICU data in.
return true;
-#endif // OS_WIN
+#elif defined(OS_LINUX)
+ // For now, expect the data file to be alongside the executable.
+ // This is sufficient while we work on unit tests, but will eventually
+ // likely live in a data directory.
+ std::wstring data_path;
+ bool path_ok = PathService::Get(base::DIR_EXE, &data_path);
+ DCHECK(path_ok);
+ u_setDataDirectory(base::SysWideToNativeMB(data_path).c_str());
+ return true;
+#endif
}
} // namespace icu_util