ext/console/console.c in console-0.2 vs ext/console/console.c in console-0.2.1
- old
+ new
@@ -47,11 +47,13 @@
wchar_t wc;
size_t num_bytes = mbrtowc(&wc, string, remaining_bytes, &mbs);
if(num_bytes == 0) rb_raise(rb_eArgError, "malformed string: NULL byte at position %ld", RSTRING_LEN(v_string) - remaining_bytes);
int width = wcwidth(wc);
- if(width == 0) rb_raise(rb_eArgError, "bad string: non-printable character");
+ /* sometimes this seems to happen! maybe it's not bad...
+ if(width == 0) rb_raise(rb_eArgError, "bad string: non-printable character at position %ld", RSTRING_LEN(v_string) - remaining_bytes);
+ */
display_width += width;
remaining_bytes -= num_bytes;
string += num_bytes; // advance string pointer
}
@@ -124,11 +126,13 @@
wchar_t wc;
size_t num_bytes = mbrtowc(&wc, string, remaining_bytes, &mbs);
if(num_bytes == 0) rb_raise(rb_eArgError, "malformed string: NULL byte at position %ld", RSTRING_LEN(v_string) - remaining_bytes);
int width = wcwidth(wc);
- if(width == 0) rb_raise(rb_eArgError, "bad string: non-printable character");
+ /* sometimes this seems to happen! maybe it's not bad...
+ if(width == 0) rb_raise(rb_eArgError, "bad string: non-printable character at position %ld", RSTRING_LEN(v_string) - remaining_bytes);
+ */
current_width += width;
remaining_bytes -= num_bytes;
string += num_bytes; // advance string pointer
}
@@ -150,10 +154,12 @@
wchar_t wc;
size_t num_bytes = mbrtowc(&wc, string_end, remaining_bytes, &mbs);
if(num_bytes == 0) rb_raise(rb_eArgError, "malformed string: NULL byte at position %ld", RSTRING_LEN(v_string) - remaining_bytes);
int width = wcwidth(wc);
- if(width == 0) rb_raise(rb_eArgError, "bad string: non-printable character");
+ /* sometimes this seems to happen! maybe it's not bad...
+ if(width == 0) rb_raise(rb_eArgError, "bad string: non-printable character at position %ld", RSTRING_LEN(v_string) - remaining_bytes);
+ */
if((current_width + width) > display_width) break; // have to stop here
current_width += width;
remaining_bytes -= num_bytes;