rspec/rules/S2132/html/rule.adoc

36 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
Failure to specify a locale for ``++String++`` case conversions means the system default encoding will be used, possibly creating problems with international characters. Such code may work fine in its "home" environment, but break in ways that are extremely difficult to diagnose for customers who use different encodings. Such bugs can be nearly, if not completely, impossible to reproduce when it's time to fix them.
=== Noncompliant code example
2022-02-04 17:28:24 +01:00
[source,html]
----
String myStr = "José is a nice guy.";
String myUcString = myStr.toUpperCase(); // Noncompliant
----
=== Compliant solution
2022-02-04 17:28:24 +01:00
[source,html]
----
String myStr = "José is a nice guy.";
String myUcString = myStr.toUpperCase(Locale.US);
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
=== duplicates: S1449
=== on 10 Oct 2014, 11:45:49 Freddy Mallet wrote:
@Ann, this ticket duplicates RSPEC-1449, either delete RSPEC-1449 or this ticket. Moreover, I would mention the fact that this is useful only for few kind of locales.
endif::env-github,rspecator-view[]