Re: [PHP-DEV] trim support for multibyte spaces

2023-10-02 Thread youkidearitai
2023年10月2日(月) 23:24 Hans Henrik Bergan : > > add a > void str_dump(const size_t strlen, const char *str) > { > printf("string(%zu) \"", strlen); > fwrite(str, strlen, 1, stdout); > printf("\"\n"); > } > > then replace the string_view stuff with > > size_t teststrlen = strlen(teststr

Re: [PHP-DEV] trim support for multibyte spaces

2023-10-02 Thread Hans Henrik Bergan
add a void str_dump(const size_t strlen, const char *str) { printf("string(%zu) \"", strlen); fwrite(str, strlen, 1, stdout); printf("\"\n"); } then replace the string_view stuff with size_t teststrlen = strlen(teststr); str_dump(teststrlen, teststr); mb_trim(&teststrlen,

Re: [PHP-DEV] trim support for multibyte spaces

2023-10-02 Thread youkidearitai
Hi, Hans. Thank you very much for your code. And sorry for late. I confirmed works fine. https://gist.github.com/youkidearitai/0018dee27353c00aebaff3bf57c5b8c6 However, this code is C++17, php-src is C code. If you would like contribute, I would like written to C code. Regards Yuya 2023年10月1日(日

Re: [PHP-DEV] trim support for multibyte spaces

2023-10-01 Thread Hans Henrik Bergan
.. probably a bunch of stuff that *could* be optimized or done better, but one i saw just now is that instead of 2x nested loops and goto, the outer loop and labels could be removed and the `goto remove_from_start_continue_2;` could be replaced with `i=-1;` eg size_t local_strlen = *strlen;

Re: [PHP-DEV] trim support for multibyte spaces

2023-10-01 Thread Hans Henrik Bergan
> If have any idea, feel free to comment to me. i think the C code would look something like void mb_trim(size_t *strlen, char **str, const size_t trim_lengths_num, const size_t *trim_lengths, const char **trim_chars) { size_t local_strlen = *strlen; char *local_str = *str; for (;;)

Re: [PHP-DEV] trim support for multibyte spaces

2023-09-30 Thread youkidearitai
2023年9月30日(土) 17:42 Saki Takamachi : > > > I also want to trim function of multibyte trim functions. > > > I think that in addition to mb_trim, > mb_ltrim and mb_rtrim are also necessary. > > Hi. > > Having a new option besides regex sounds like a good idea for me, as a user > of a language that b

Re: [PHP-DEV] trim support for multibyte spaces

2023-09-30 Thread Saki Takamachi
> I also want to trim function of multibyte trim functions. > I think that in addition to mb_trim, mb_ltrim and mb_rtrim are also necessary. Hi. Having a new option besides regex sounds like a good idea for me, as a user of a language that benefits from `mb_trim()`. Perhaps users are more intu

[PHP-DEV] trim support for multibyte spaces

2023-09-28 Thread youkidearitai
Hi, Internals. When I was watching https://github.com/php/php-src/issues/9216, I also want to trim function of multibyte trim functions. I think that in addition to mb_trim, mb_ltrim and mb_rtrim are also necessary. What do you think about this? Regards Yuya -- PHP Internals - PHP Runtime Dev