Fixed unescaping of all escaped C String characters.

Signed-off-by: Julian Bäume <julian@svg4all.de>

Conflicts:
	lib/po.js
This commit is contained in:
Candid Dauth 2012-09-23 01:39:44 +02:00 committed by Julian Bäume
parent d8fc514359
commit 4cfebdee80

View File

@ -119,8 +119,32 @@ PO.parse = function (data) {
function extract(string) {
string = trim(string);
string = string.replace(/^[^"]*"|"$/g, '');
string = string.replace(/\\"/g, '"');
string = string.replace(/\\\\/g, '\\');
string = string.replace(/\\([abtnvfr'"\\?]|([0-7]{3})|x([0-9a-fA-F]{2}))/g, function (match, esc, oct, hex) {
if (oct) {
return String.fromCharCode(parseInt(oct, 8));
}
if (hex) {
return String.fromCharCode(parseInt(hex, 16));
}
switch (esc) {
case 'a':
return '\x07';
case 'b':
return '\b';
case 't':
return '\t';
case 'n':
return '\n';
case 'v':
return '\v';
case 'f':
return '\f';
case 'r':
return '\r';
default:
return esc;
}
});
return string;
}