--- parser3/src/classes/string.C 2026/11/01 14:41:57 1.268 +++ parser3/src/classes/string.C 2026/11/26 21:25:03 1.270 @@ -22,7 +22,7 @@ #include "pa_vregex.h" #include "pa_charsets.h" -volatile const char * IDENT_STRING_C="$Id: string.C,v 1.268 2026/11/01 14:41:57 moko Exp $"; +volatile const char * IDENT_STRING_C="$Id: string.C,v 1.270 2026/11/26 21:25:03 moko Exp $"; // class @@ -158,12 +158,8 @@ static void _left(Request& r, MethodPara static void _right(Request& r, MethodParams& params) { int sn=params.as_int(0, "n must be int", r); - if(sn>0){ - size_t n=sn; - const String& string=GET_SELF(r, VString).string(); - size_t length=string.length(r.charsets.source()); - r.write(n0) + r.write(GET_SELF(r, VString).string().right(r.charsets.source(), sn)); } static void _mid(Request& r, MethodParams& params) { @@ -173,20 +169,16 @@ static void _mid(Request& r, MethodParam if(begin<0) throw Exception(PARSER_RUNTIME, 0, "p(%d) must be >=0", begin); - size_t end; - size_t length=0; + size_t end=string.length(); // to the end of the string (the length in bytes is not less than in characters) if(params.count()>1) { int n=params.as_int(1, "n must be int", r); if(n<0) throw Exception(PARSER_RUNTIME, 0, "n(%d) must be >=0", n); end=begin+n; - } else { - length=string.length(r.charsets.source()); - end=length; } - r.write(string.mid(r.charsets.source(), begin, end, length)); + r.write(string.mid(r.charsets.source(), begin, end)); } static void _pos(Request& r, MethodParams& params) { @@ -631,7 +623,7 @@ static void _save(Request& r, MethodPara // ^file.save[filespec;$.charset[] $.append(true)] int valid_options=0; if(Value* vcharset_name=options->get(PA_CHARSET_NAME)){ - asked_charset=&pa_charsets.get(vcharset_name->as_string()); + asked_charset=&pa_charsets.get_file_charset(vcharset_name->as_string()); valid_options++; } if(Value* vappend=options->get(MODE_APPEND)){