Modified: MacRuby/trunk/bignum.c (4420 => 4421)
--- MacRuby/trunk/bignum.c 2010-08-11 01:54:56 UTC (rev 4420)
+++ MacRuby/trunk/bignum.c 2010-08-11 01:55:41 UTC (rev 4421)
@@ -12,6 +12,7 @@
#include "ruby/macruby.h"
#include "objc.h"
+#include "encoding.h"
#include <math.h>
#include <float.h>
@@ -593,6 +594,7 @@
long len;
StringValue(str);
+ str_check_ascii_compatible(str);
if (badcheck) {
s = StringValueCStr(str);
}
Modified: MacRuby/trunk/encoding.h (4420 => 4421)
--- MacRuby/trunk/encoding.h 2010-08-11 01:54:56 UTC (rev 4420)
+++ MacRuby/trunk/encoding.h 2010-08-11 01:55:41 UTC (rev 4421)
@@ -359,6 +359,14 @@
rb_str_t *replacement_string_for_encoding(rb_encoding_t* enc);
void str_replace_with_string(rb_str_t *self, rb_str_t *source);
+static inline void
+str_check_ascii_compatible(VALUE str)
+{
+ if (IS_RSTR(str) && !RSTR(str)->encoding->ascii_compatible) {
+ rb_raise(rb_eEncCompatError, "ASCII incompatible encoding: %s",
+ RSTR(str)->encoding->public_name);
+ }
+}
#if defined(__cplusplus)
} // extern "C"