Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Question about mb_metastrlen
- X-seq: zsh-workers 36972
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Question about mb_metastrlen
- Date: Tue, 27 Oct 2015 09:31:02 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=d0PutZon7JhOw2c25GkzFs/c37CwzEmO35hxiTELn4Y=; b=ziUKKnZECPAZTOKMxtOtZr0vseCrWssAhUEQVwylhjpWHoGDv8RbsDtHwXEouValI7 ugAkCLDrGA1DOi1B5lW9OjmNxzzNiwlFHZyAMkr9craAmB2hXlKWIgYY8M642gjLbBvN qcXDg7HuQ8OGXwFCfO+V/OhG+sf4weK6vSGQeIY6HGvuNHxJcAXQsP122yb+qYcsDLEk /xt7bb0m+VoKDpZbQIEYZUe1ubkAkdEuUXzx1dfFi+nw1AIXQF5jh7EoFlcbX5lynfm4 vXw1S5jLrnnG8P6oS4/6+Md9+P0RBh2Cp8+wwv7VffvkTvkENmrurAJrk/TXmeZEz+BT L6Yw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hello,
the function counts bytes in last incomplete wide character:
ret = mbrtowc(&wc, &inchar, 1, &mb_shiftstate);
if (ret == MB_INCOMPLETE) {
num_in_char++;
} else {
When returning, it makes use of the count:
/* If incomplete, treat remainder as trailing single bytes */
return num + num_in_char;
Strings are stored in wchar_t arrays. The incomplete character will
occupy single index, correct? So maybe the return should be:
return num + ( num_in_char > 0 ? 1 : 0 );
?
Best regards,
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author