Permalink
Browse files

fixed ByteString#encoding to always return US_ASCII (for now)

  • Loading branch information...
1 parent ffd71a1 commit 022cd7ca946ddfb6c6eb89e880027d64ddc80112 @lrz lrz committed Jun 5, 2009
Showing with 11 additions and 8 deletions.
  1. +11 −8 encoding.c
View
@@ -498,17 +498,20 @@ rb_enc_find2(VALUE name)
rb_encoding *
rb_enc_get(VALUE obj)
{
- int type = TYPE(obj);
- if (type == T_STRING) {
- CFStringEncoding enc = CFStringGetFastestEncoding((CFStringRef)obj);
- if (enc == kCFStringEncodingInvalidId)
- return NULL;
- return rb_enc_to_enc_ptr(enc_make(&enc));
+ CFStringEncoding enc = kCFStringEncodingInvalidId;
+
+ switch (TYPE(obj)) {
+ case T_STRING:
+ enc = *(VALUE *)obj == rb_cByteString
+ ? kCFStringEncodingASCII
+ : CFStringGetFastestEncoding((CFStringRef)obj);
+ break;
}
- else {
- /* TODO */
+
+ if (enc == kCFStringEncodingInvalidId) {
return NULL;
}
+ return rb_enc_to_enc_ptr(enc_make(&enc));
}
rb_encoding *

0 comments on commit 022cd7c

Please sign in to comment.