skia2/third_party/icu/SkLoadICU.h
Hal Canary 0e07ad7fe7 ICU on windows
Change-Id: Ib1a2f017d96c5157c60d512332fddfef77c5ae8e
Reviewed-on: https://skia-review.googlesource.com/103001
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
2018-02-08 19:36:49 +00:00

53 lines
1.4 KiB
C

/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef load_icu_DEFINED
#define load_icu_DEFINED
#include "SkTypes.h"
#ifdef SK_BUILD_FOR_WIN
#include "../private/SkLeanWindows.h"
#include "unicode/uvernum.h"
#include "unicode/udata.h"
#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
inline void SkLoadICU() {
HMODULE module = LoadLibrary(ICU_UTIL_DATA_SHARED_MODULE_NAME);
if (!module) {
SK_ABORT("Failed to load " ICU_UTIL_DATA_SHARED_MODULE_NAME "\n");
}
FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
if (!addr) {
SK_ABORT("Symbol " ICU_UTIL_DATA_SYMBOL " missing in "
ICU_UTIL_DATA_SHARED_MODULE_NAME ".\n");
}
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
if (err != U_ZERO_ERROR) {
SkDebugf("udata_setCommonData() returned %d.\n", (int)err);
SK_ABORT("");
}
udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
if (err != U_ZERO_ERROR) {
SkDebugf("udata_setFileAccess() returned %d.\n", (int)err);
SK_ABORT("");
}
}
#undef ICU_UTIL_DATA_SHARED_MODULE_NAME
#undef ICU_UTIL_DATA_SYMBOL
#else
inline void SkLoadICU() {}
#endif // SK_BUILD_FOR_WIN
#endif // load_icu_DEFINED