共用方式為


Locale.ToString Method

Definition

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below: <blockquote> language + "" + country + "" + (variant + "#" | "#") + script + "" + extensions </blockquote>

        Language is always lower case, country is always upper case, script is always title
        case, and extensions are always lower case.
[Android.Runtime.Register("toString", "()Ljava/lang/String;", "")]
public override sealed string? ToString ();
[<Android.Runtime.Register("toString", "()Ljava/lang/String;", "")>]
override this.ToString : unit -> string

Returns

A string representation of the Locale, for debugging.

Attributes

Remarks

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below: <blockquote> language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions </blockquote>

Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case. Extensions and private use subtags will be in canonical order as explained in #toLanguageTag.

When the locale has neither script nor extensions, the result is the same as in Java 6 and prior.

If both the language and country fields are missing, this function will return the empty string, even if the variant, script, or extensions field is present (you can't have a locale with just a variant, the variant must accompany a well-formed language or country code).

If script or extensions are present and variant is missing, no underscore is added before the "#".

This behavior is designed to support debugging and to be compatible with previous uses of toString that expected language, country, and variant fields only. To represent a Locale as a String for interchange purposes, use #toLanguageTag.

Examples: <ul> <li>en</li> <li>de_DE</li> <li>_GB</li> <li>en_US_WIN</li> <li>de__POSIX</li> <li>zh_CN_#Hans</li> <li>zh_TW_#Hant_x-java</li> <li>th_TH_TH_#u-nu-thai</li></ul>

Java documentation for java.util.Locale.toString().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to