Trims whitespaces from the right end of the input utf8 sequence
| 342 | |
| 343 | // Trims whitespaces from the right end of the input utf8 sequence |
| 344 | FORCE_INLINE |
| 345 | const char* rtrim_utf8(gdv_int64 context, const char* data, gdv_int32 data_len, |
| 346 | int32_t* out_len) { |
| 347 | if (data_len == 0) { |
| 348 | *out_len = 0; |
| 349 | return ""; |
| 350 | } |
| 351 | |
| 352 | gdv_int32 end = data_len - 1; |
| 353 | // end denotes the last position of non-space characters in the input string |
| 354 | while (end >= 0 && data[end] == ' ') { |
| 355 | --end; |
| 356 | } |
| 357 | |
| 358 | *out_len = end + 1; |
| 359 | return data; |
| 360 | } |
| 361 | |
| 362 | // Trims whitespaces from both the ends of the input utf8 sequence |
| 363 | FORCE_INLINE |