File tree Expand file tree Collapse file tree 2 files changed +2
-0
lines changed Expand file tree Collapse file tree 2 files changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -966,6 +966,7 @@ defmodule String do
966
966
967
967
def capitalize ( string , mode ) when is_binary ( string ) do
968
968
case :unicode_util . gc ( string ) do
969
+ [ gc ] -> grapheme_to_binary ( :string . titlecase ( [ gc ] ) )
969
970
[ gc , rest ] -> grapheme_to_binary ( :string . titlecase ( [ gc ] ) ) <> downcase ( rest , mode )
970
971
[ gc | rest ] -> grapheme_to_binary ( :string . titlecase ( [ gc ] ) ) <> downcase ( rest , mode )
971
972
[ ] -> ""
Original file line number Diff line number Diff line change @@ -254,6 +254,7 @@ defmodule StringTest do
254
254
255
255
test "capitalize/1" do
256
256
assert String . capitalize ( "" ) == ""
257
+ assert String . capitalize ( "1" ) == "1"
257
258
assert String . capitalize ( "abc" ) == "Abc"
258
259
assert String . capitalize ( "ABC" ) == "Abc"
259
260
assert String . capitalize ( "c b a" ) == "C b a"
You can’t perform that action at this time.
0 commit comments