2
0
Эх сурвалжийг харах

StringHelper.capitalize instead of String.capitalize

Alexander Kuzmenko 6 жил өмнө
parent
commit
1e871fdeb9

+ 10 - 1
src/core/stringHelper.ml

@@ -7,4 +7,13 @@ let uppercase s =
 				Bytes.set bytes idx (Char.chr (code - 32))
 		)
 		bytes;
-	Bytes.to_string bytes
+	Bytes.to_string bytes
+
+let capitalize s =
+	if String.length s = 0 then ""
+	else
+		let bytes = Bytes.of_string s in
+		let code = Char.code (Bytes.get bytes 0) in
+		if 97 <= code && code <= 122 then
+			Bytes.set bytes 0 (Char.chr (code - 32));
+		Bytes.to_string bytes

+ 1 - 1
src/generators/genphp7.ml

@@ -1367,7 +1367,7 @@ class code_writer (ctx:Common.context) hx_type_path php_name =
 										| [] -> [name]
 										| _ -> rest
 									);
-									String.capitalize name
+									StringHelper.capitalize name
 						and added = ref false
 						and alias = ref (get_type_name type_path) in
 						let alias_upper = ref (StringHelper.uppercase !alias) in