mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibLocale: Inline a couple of ICU string conversion methods
This just allows using the ICU header within LibUnicode, without having to link against LibLocale. Eventually, I think it will make sense to combine LibUnicode & LibLocale back into a single library. They were separated to remove the large CLDR data library from LibUnicode since most users did not need it. But that is not much of a concern now.
This commit is contained in:
parent
1feef17bf7
commit
187349e4db
Notes:
sideshowbarker
2024-07-17 05:09:48 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/187349e4db Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/201
2 changed files with 12 additions and 16 deletions
|
@ -15,7 +15,6 @@
|
||||||
#include <unicode/locdspnm.h>
|
#include <unicode/locdspnm.h>
|
||||||
#include <unicode/numsys.h>
|
#include <unicode/numsys.h>
|
||||||
#include <unicode/tznames.h>
|
#include <unicode/tznames.h>
|
||||||
#include <unicode/unistr.h>
|
|
||||||
|
|
||||||
namespace Locale {
|
namespace Locale {
|
||||||
|
|
||||||
|
@ -116,16 +115,6 @@ icu::TimeZoneNames& LocaleData::time_zone_names()
|
||||||
return *m_time_zone_names;
|
return *m_time_zone_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
icu::UnicodeString icu_string(StringView string)
|
|
||||||
{
|
|
||||||
return icu::UnicodeString::fromUTF8(icu_string_piece(string));
|
|
||||||
}
|
|
||||||
|
|
||||||
icu::StringPiece icu_string_piece(StringView string)
|
|
||||||
{
|
|
||||||
return { string.characters_without_null_termination(), static_cast<i32>(string.length()) };
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<icu::UnicodeString> icu_string_list(ReadonlySpan<String> strings)
|
Vector<icu::UnicodeString> icu_string_list(ReadonlySpan<String> strings)
|
||||||
{
|
{
|
||||||
Vector<icu::UnicodeString> result;
|
Vector<icu::UnicodeString> result;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <unicode/locid.h>
|
#include <unicode/locid.h>
|
||||||
#include <unicode/stringpiece.h>
|
#include <unicode/stringpiece.h>
|
||||||
|
#include <unicode/unistr.h>
|
||||||
#include <unicode/utypes.h>
|
#include <unicode/utypes.h>
|
||||||
#include <unicode/uversion.h>
|
#include <unicode/uversion.h>
|
||||||
|
|
||||||
|
@ -24,7 +25,6 @@ class DateTimePatternGenerator;
|
||||||
class LocaleDisplayNames;
|
class LocaleDisplayNames;
|
||||||
class NumberingSystem;
|
class NumberingSystem;
|
||||||
class TimeZoneNames;
|
class TimeZoneNames;
|
||||||
class UnicodeString;
|
|
||||||
U_NAMESPACE_END
|
U_NAMESPACE_END
|
||||||
|
|
||||||
namespace Locale {
|
namespace Locale {
|
||||||
|
@ -63,18 +63,25 @@ private:
|
||||||
Optional<DigitalFormat> m_digital_format;
|
Optional<DigitalFormat> m_digital_format;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr bool icu_success(UErrorCode code)
|
constexpr bool icu_success(UErrorCode code)
|
||||||
{
|
{
|
||||||
return static_cast<bool>(U_SUCCESS(code));
|
return static_cast<bool>(U_SUCCESS(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr bool icu_failure(UErrorCode code)
|
constexpr bool icu_failure(UErrorCode code)
|
||||||
{
|
{
|
||||||
return static_cast<bool>(U_FAILURE(code));
|
return static_cast<bool>(U_FAILURE(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
icu::UnicodeString icu_string(StringView string);
|
ALWAYS_INLINE icu::StringPiece icu_string_piece(StringView string)
|
||||||
icu::StringPiece icu_string_piece(StringView string);
|
{
|
||||||
|
return { string.characters_without_null_termination(), static_cast<i32>(string.length()) };
|
||||||
|
}
|
||||||
|
|
||||||
|
ALWAYS_INLINE icu::UnicodeString icu_string(StringView string)
|
||||||
|
{
|
||||||
|
return icu::UnicodeString::fromUTF8(icu_string_piece(string));
|
||||||
|
}
|
||||||
|
|
||||||
Vector<icu::UnicodeString> icu_string_list(ReadonlySpan<String> strings);
|
Vector<icu::UnicodeString> icu_string_list(ReadonlySpan<String> strings);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue