You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== lsprintf ==
locale, formatString, array(parameters...) |- ! scope="row" | Throws | [[../objects/ms.lang.FormatException|ms.lang.FormatException]]
[[../objects/ms.lang.InsufficientArgumentsException|ms.lang.InsufficientArgumentsException]]
[[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.3.1 |- ! scope="row" | Restricted |
[[../../Optimizer#OPTIMIZE_DYNAMIC|OPTIMIZE_DYNAMIC]] |} === Usages ===
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output might be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output might be:
Copy Code
The output might be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Copy Code
The output would be:
Returns a string formatted to the given formatString specification, using the parameters passed in. Locale should be a string in format, for instance, en_US, nl_NL, no_NO... Which locales are available depends on your system. Use null to use the system's locale. The formatString should be formatted according to [http://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax this standard], with the caveat that the parameter types are automatically cast to the appropriate type, if possible. Calendar/time specifiers, (t and T) expect an integer which represents unix time, but are otherwise valid. All format specifiers in the documentation are valid.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| lsprintf
|-
! scope="row" | Returns
| string
|-
! scope="row" | Usages
| locale, formatString, parameters... locale, formatString, array(parameters...) |- ! scope="row" | Throws | [[../objects/ms.lang.FormatException|ms.lang.FormatException]]
[[../objects/ms.lang.InsufficientArgumentsException|ms.lang.InsufficientArgumentsException]]
[[../objects/ms.lang.CastException|ms.lang.CastException]] |- ! scope="row" | Since | 3.3.1 |- ! scope="row" | Restricted |
No
|-
! scope="row" | Optimizations
| [[../../Optimizer#CONSTANT_OFFLINE|CONSTANT_OFFLINE]] [[../../Optimizer#OPTIMIZE_DYNAMIC|OPTIMIZE_DYNAMIC]] |} === Usages ===
lsprintf(locale, formatString, parameters...)
lsprintf(locale, formatString, array(parameters...))=== Examples === ====Example 1==== Basic usage Given the following code:
lsprintf('en_US', '%d', 1)

1 {{function|lsprintf}}('en_US', '%d', 1)
:1====Example 2==== Multiple arguments Given the following code:
lsprintf('en_US', '%d%d', 1, '2')

1 {{function|lsprintf}}('en_US', '%d%d', 1, '2')
:12====Example 3==== Multiple arguments in an array Given the following code:
lsprintf('en_US', '%d%d', array(1, 2))

1 {{function|lsprintf}}('en_US', '%d%d', {{function|array}}(1, 2))
:12====Example 4==== Compile error, missing parameters Given the following code:
lsprintf('en_US', '%d')

1 {{function|lsprintf}}('en_US', '%d')
Causes compile error: The specified format string: "%d" expects 1 argument(s), but 0 were provided.====Example 5==== Other formatting: float with precision (using integer) Given the following code:
lsprintf('en_US', '%07.3f', 4)

1 {{function|lsprintf}}('en_US', '%07.3f', 4)
:004.000====Example 6==== Other formatting: float with precision (with rounding) Given the following code:
lsprintf('en_US', '%07.3f', 3.4567)

1 {{function|lsprintf}}('en_US', '%07.3f', 3.4567)
:003.457====Example 7==== Other formatting: float with precision in a different locale (with rounding) Given the following code:
lsprintf('nl_NL', '%07.3f', 3.4567)

1 {{function|lsprintf}}('nl_NL', '%07.3f', 3.4567)
:003,457====Example 8==== Other formatting: time Given the following code:
lsprintf('en_US', '%1$tm %1$te,%1$tY', time())

1 {{function|lsprintf}}('en_US', '%1$tm %1$te,%1$tY', {{function|time}}())
:06 13,2013====Example 9==== Literal percent sign Given the following code:
lsprintf('en_US', '%'.'%') // The concatenation is to prevent the website's template system from overriding. It is not needed.

1 {{function|lsprintf}}('en_US', '%'.'%') // The concatenation is to prevent the website's template system from overriding. It is not needed.
%====Example 10==== Hexidecimal formatting Given the following code:
lsprintf('en_US', '%x', 15)

1 {{function|lsprintf}}('en_US', '%x', 15)
:f====Example 11==== Other formatting: character Given the following code:
lsprintf('en_US', '%c', 's')

1 {{function|lsprintf}}('en_US', '%c', 's')
:s====Example 12==== Other formatting: character (with capitalization) Given the following code:
lsprintf('en_US', '%C', 's')

1 {{function|lsprintf}}('en_US', '%C', 's')
:S====Example 13==== Other formatting: scientific notation Given the following code:
lsprintf('en_US', '%e', '2345')

1 {{function|lsprintf}}('en_US', '%e', '2345')
:2.345000e+03====Example 14==== Other formatting: plain string Given the following code:
lsprintf('en_US', '%s', 'plain string')

1 {{function|lsprintf}}('en_US', '%s', 'plain string')
:plain string====Example 15==== Other formatting: boolean Given the following code:
lsprintf('en_US', '%b', 1)

1 {{function|lsprintf}}('en_US', '%b', 1)
:true====Example 16==== Other formatting: boolean (with capitalization) Given the following code:
lsprintf('en_US', '%B', 0)

1 {{function|lsprintf}}('en_US', '%B', 0)
:FALSE====Example 17==== Other formatting: hash code Given the following code:
lsprintf('en_US', '%h', 'will be hashed')

1 {{function|lsprintf}}('en_US', '%h', 'will be hashed')
:7c4711dc===See Also===
[[API/functions/sprintf.html|sprintf]]
, [[API/functions/get_locales.html|get_locales]]
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)