|
|
| version 1.268, 2026/11/01 14:41:57 | version 1.270, 2026/11/26 21:25:03 |
|---|---|
| Line 158 static void _left(Request& r, MethodPara | Line 158 static void _left(Request& r, MethodPara |
| static void _right(Request& r, MethodParams& params) { | static void _right(Request& r, MethodParams& params) { |
| int sn=params.as_int(0, "n must be int", r); | int sn=params.as_int(0, "n must be int", r); |
| if(sn>0){ | if(sn>0) |
| size_t n=sn; | r.write(GET_SELF(r, VString).string().right(r.charsets.source(), sn)); |
| const String& string=GET_SELF(r, VString).string(); | |
| size_t length=string.length(r.charsets.source()); | |
| r.write(n<length ? string.mid(r.charsets.source(), length-n, length, length) : string); | |
| } | |
| } | } |
| static void _mid(Request& r, MethodParams& params) { | static void _mid(Request& r, MethodParams& params) { |
| Line 173 static void _mid(Request& r, MethodParam | Line 169 static void _mid(Request& r, MethodParam |
| if(begin<0) | if(begin<0) |
| throw Exception(PARSER_RUNTIME, 0, "p(%d) must be >=0", begin); | throw Exception(PARSER_RUNTIME, 0, "p(%d) must be >=0", begin); |
| size_t end; | size_t end=string.length(); // to the end of the string (the length in bytes is not less than in characters) |
| size_t length=0; | |
| if(params.count()>1) { | if(params.count()>1) { |
| int n=params.as_int(1, "n must be int", r); | int n=params.as_int(1, "n must be int", r); |
| if(n<0) | if(n<0) |
| throw Exception(PARSER_RUNTIME, 0, "n(%d) must be >=0", n); | throw Exception(PARSER_RUNTIME, 0, "n(%d) must be >=0", n); |
| end=begin+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) { | static void _pos(Request& r, MethodParams& params) { |
| Line 631 static void _save(Request& r, MethodPara | Line 623 static void _save(Request& r, MethodPara |
| // ^file.save[filespec;$.charset[] $.append(true)] | // ^file.save[filespec;$.charset[] $.append(true)] |
| int valid_options=0; | int valid_options=0; |
| if(Value* vcharset_name=options->get(PA_CHARSET_NAME)){ | 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++; | valid_options++; |
| } | } |
| if(Value* vappend=options->get(MODE_APPEND)){ | if(Value* vappend=options->get(MODE_APPEND)){ |