Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted Java array-style ref/out/return values into ref/out parameters in .NET (Fixes #57) #61

Merged
merged 19 commits into from
Nov 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ed5da25
BREAKING: ICU4N.Impl.Utility::ParseInteger(): Converted pos parameter…
NightOwl888 Nov 17, 2023
acdf02f
BREAKING: ICU4N.Impl.Utility::ParseUnicodeIdentifier(): Converted pos…
NightOwl888 Nov 17, 2023
b8e2d2d
BREAKING: ICU4N.Impl.Utility::ParseNumber(): Changed pos parameter fr…
NightOwl888 Nov 17, 2023
8f1d1e2
BREAKING: ICU4N.Impl.Utility (EncodeRun + AppendEncodedByte): Convert…
NightOwl888 Nov 17, 2023
f9b2780
BREAKING: ICU4N.Impl.Utility::ParseChar(): Converted pos parameter fr…
NightOwl888 Nov 17, 2023
46229ce
ICU4N.Transliterator.Text.TransliteratorIDParser (ParseFilterID() + P…
NightOwl888 Nov 17, 2023
a1fe698
ICU4N.Transliterator.Text.TransliteratorIDParser::ParseGlobalFilter()…
NightOwl888 Nov 17, 2023
41ceea3
ICU4N.Transliterator.Text.TransliteratorIDParser::ParseCompoundID(): …
NightOwl888 Nov 17, 2023
0a1cdf1
BREAKING: ICU4N.Text.IUnicodeMatcher::Matches(): Changed offset param…
NightOwl888 Nov 17, 2023
4a37d18
BREAKING: ICU4N.Text.IUnicodeReplacer::Replace(): Changed cursor para…
NightOwl888 Nov 17, 2023
c527f4b
BREAKING: ICU4N.Impl.ICUResourceBundle::GetFunctionalEquivalent() + I…
NightOwl888 Nov 17, 2023
966f0c7
BREAKING: ICU4N.Impl.Int32TrieBuilder::GetValue(): Changed inBlockZer…
NightOwl888 Nov 17, 2023
5a7192d
ICU4N.Text.DictionaryMatcher::Matches(): Changed count parameter from…
NightOwl888 Nov 17, 2023
9d13619
ICU4N.Globalization.UCultureInfo::ParseTagString(): Converted tags st…
NightOwl888 Nov 17, 2023
5a69a94
ICU4N.Impl.Grego::FloorDivide(): Changed remainder parameter from lon…
NightOwl888 Nov 17, 2023
787c6c9
BREAKING: ICU4N.Impl.Grego (DayToFields() + TimeToFields()): Changed …
NightOwl888 Nov 17, 2023
e5e9c46
ICU4N.Impl.UCharacterName::AddGroupName(): Changed return array to ou…
NightOwl888 Nov 18, 2023
36f9aae
.build/nowarn.props: Disabled LuceneDev1003 and LuceneDev1004 warning…
NightOwl888 Nov 21, 2023
063cac6
ICU4N.Text.TransliteratorIDParser::IDtoSTV(): Converted return array …
NightOwl888 Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ICU4N.Globalization.UCultureInfo::ParseTagString(): Converted tags st…
…ring array parameter to out parameters for language, script, and region (see #57)
  • Loading branch information
NightOwl888 committed Nov 23, 2023
commit 9d136192c0a38270f13491aa25d642955d5f0892
46 changes: 23 additions & 23 deletions src/ICU4N/Support/Globalization/UCultureInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2458,12 +2458,13 @@ internal static bool TryParseAcceptLanguage(string acceptLanguage, bool isLenien
/// <stable>ICU 4.0</stable>
public static UCultureInfo AddLikelySubtags(UCultureInfo culture)
{
string[] tags = new string[3];
string? trailing = null;

int trailingIndex = ParseTagString(
culture.localeID,
tags);
out string language,
out string script,
out string region);

if (trailingIndex < culture.localeID.Length)
{
Expand All @@ -2472,9 +2473,9 @@ public static UCultureInfo AddLikelySubtags(UCultureInfo culture)

string? newLocaleID =
CreateLikelySubtagsString(
tags[0],
tags[1],
tags[2],
language,
script,
region,
trailing);

return newLocaleID == null ? culture : new UCultureInfo(newLocaleID);
Expand Down Expand Up @@ -2562,15 +2563,12 @@ internal enum Minimize // ICU4N specific - marked internal instead of public, si
[Obsolete("This API is ICU internal only.")]
internal static UCultureInfo MinimizeSubtags(UCultureInfo loc, Minimize fieldToFavor) // ICU4N specific - marked internal instead of public, since the functionality is obsolete
{
string[] tags = new string[3];

int trailingIndex = ParseTagString(
loc.localeID,
tags);
out string originalLang,
out string originalScript,
out string originalRegion);

string originalLang = tags[0];
string originalScript = tags[1];
string originalRegion = tags[2];
string? originalTrailing = null;

if (trailingIndex < loc.localeID.Length)
Expand Down Expand Up @@ -2979,9 +2977,11 @@ internal static string CreateTagString(string? lang, string? script, string? reg
/// <para/>This function does not return the canonical strings for the unknown script and region.
/// </summary>
/// <param name="localeID">The locale ID to parse.</param>
/// <param name="tags">An array of three string references to return the subtag strings.</param>
/// <param name="language">The returned language id.</param>
/// <param name="script">The returned script id.</param>
/// <param name="region">The returned region (country id).</param>
/// <returns>The number of chars of the localeID parameter consumed.</returns>
private static int ParseTagString(string localeID, string[] tags)
private static int ParseTagString(string localeID, out string language, out string script, out string region)
{
#if FEATURE_SPAN
using var parser = new LocaleIDParser(stackalloc char[CharStackBufferSize], localeID);
Expand All @@ -2990,34 +2990,34 @@ private static int ParseTagString(string localeID, string[] tags)
#endif

string lang = parser.GetLanguage();
string script = parser.GetScript();
string region = parser.GetCountry();
string scr = parser.GetScript();
string reg = parser.GetCountry();

if (string.IsNullOrEmpty(lang))
{
tags[0] = UndefinedLanguage;
language = UndefinedLanguage;
}
else
{
tags[0] = lang;
language = lang;
}

if (script.Equals(UndefinedScript))
if (scr.Equals(UndefinedScript))
{
tags[1] = "";
script = "";
}
else
{
tags[1] = script;
script = scr;
}

if (region.Equals(UndefinedRegion))
if (reg.Equals(UndefinedRegion))
{
tags[2] = "";
region = "";
}
else
{
tags[2] = region;
region = reg;
}

/*
Expand Down