Posted
about 14 years
ago
by
Dj
Note that you have a bug.
hash_map["'"] = '''; should only be added when quote_style is ENT_QUOTES, otherwise the single quote will be allways converted independent of the quote style specified
|
Posted
about 14 years
ago
by
Dj
A fix to my previous post:
The last character in the last regexp should be an '*' instead of the '?':
Replace:
var str = (path + '').replace(/^[\/\\]+$/, '').replace(/^.*[\/\\]([^\/\\]+)[\/\\]?/g, '$1');
With:
var str = (path + '').replace(/^[\/\\]+$/, '').replace(/^.*[\/\\]([^\/\\]+)[\/\\]*/g, '$1');
|
Posted
about 14 years
ago
by
Dj
Note that when the input ends with one or more slashes, PHP ignores them and returns the word before them.
'///b///' result is 'b'
'///\\//' result is '' (an empty string)
To return values like PHP the code should be:
function basename(path
|
Posted
about 14 years
ago
by
Brett Zamir
@dude: OK!!!! :) (I also applied in Git to some other functions using PI or LN10.)
|
Posted
about 14 years
ago
by
Brett Zamir
Hello Everyone,
If anyone has bugs to report, please report them at https://github.com/kvz/phpjs/issues (ideally labeled as "Bug" if the system lets you). The comments system has been great for inviting contributions, but with limited time for many
|
Posted
about 14 years
ago
by
Luke Scott
I don't know who added the "dec = this.utf8_decode(dec);" bit, but this is NOT correct. This line causes raw binary data to be mangled. Removing this line fixes the problem.
Base64 does not, and should not, care about the charset. If you are
|
Posted
about 14 years
ago
by
|
Posted
about 14 years
ago
by
Brett Zamir
@Alberto Ruiz: You really should try posting in a help forum like StackOverflow (tagged with "PHP"), as this page is just about our JavaScript implementation. Try using "var_dump" instead of "echo" to ensure that the string is of the right length and not containing extra characters or something.
|
Posted
about 14 years
ago
by
Brett Zamir
@Pier Paolo Ramon: Good catch! Thanks--fixed in Git... (This function as with many others still needs to support reliably ordered associative arrays--see PHPJS_Array() in array().)
|
Posted
about 14 years
ago
by
Mike Speciner
This does not work for negative arg. It also suffers from poor precision for |arg| << 1.
To fix the first problem, try
return Math.log(Math.abs(arg) + Math.sqrt(arg * arg + 1))*(arg<0?-1:1);
The second problem is much harder to fix; best
|