Browse Source

- php : fixed issue 169

Franco Ponticelli 15 years ago
parent
commit
b80aa1fbf0
2 changed files with 3 additions and 3 deletions
  1. 2 2
      genphp.ml
  2. 1 1
      std/php/Boot.hx

+ 2 - 2
genphp.ml

@@ -617,11 +617,11 @@ and gen_string_call ctx s e el =
 		concat ctx ", " (gen_value ctx) el;
 		spr ctx ")"
 	| "charAt" ->
-		spr ctx "substr(";
+		spr ctx "_hx_char_at(";
 		gen_value ctx e;
 		spr ctx ", ";
 		concat ctx ", " (gen_value ctx) el;
-		spr ctx ", 1)"
+		spr ctx ")"
 	| "cca" ->
 		spr ctx "ord(";
 		gen_value ctx e;

+ 1 - 1
std/php/Boot.hx

@@ -208,7 +208,7 @@ function _hx_cast($v, $type) {
 	}
 }
 
-function _hx_char_at($o, $i) { return substr($o, $i, 1); }
+function _hx_char_at($o, $i) { $c = substr($o, $i, 1); return FALSE === $c ? '' : $c; }
 
 function _hx_char_code_at($s, $pos) {
 	if($pos < 0 || $pos >= strlen($s)) return null;