@@ -11,6 +11,27 @@ static REPROps *this_repr;
11
11
static wrap_object_t wrap_object_func ;
12
12
static create_stable_t create_stable_func ;
13
13
14
+ /* This is what Parrot_str_new_from_cstring does but that isn't exported. */
15
+ static STRING *
16
+ new_from_cstring (PARROT_INTERP , const char * buffer , STRING * encodingname )
17
+ {
18
+ STRING * result = STRINGNULL ;
19
+ if (buffer ) {
20
+ const STR_VTABLE * encoding = STRING_IS_NULL (encodingname ) ?
21
+ Parrot_platform_encoding_ptr :
22
+ Parrot_find_encoding_by_string (interp , encodingname );
23
+ if (encoding == NULL )
24
+ Parrot_ex_throw_from_c_args (interp , NULL ,
25
+ EXCEPTION_INVALID_ENCODING ,
26
+ "Invalid encoding" );
27
+ else {
28
+ int size = strlen (buffer );
29
+ result = Parrot_str_new_init (interp , buffer , size , encoding , 0 );
30
+ }
31
+ }
32
+ return result ;
33
+ }
34
+
14
35
static void set_str (PARROT_INTERP , STable * st , void * data , STRING * value ) {
15
36
CStrBody * body = (CStrBody * ) data ;
16
37
PMC * old_ctx , * cappy , * meth , * enc_pmc ;
@@ -46,7 +67,7 @@ static void set_str(PARROT_INTERP, STable *st, void *data, STRING *value) {
46
67
Parrot_ex_throw_from_c_args (interp , NULL , EXCEPTION_INVALID_OPERATION ,
47
68
"Unknown encoding passed to CStr representation" );
48
69
49
- body -> cstr = Parrot_str_to_encoded_cstring (interp , value , encoding );
70
+ body -> cstr = new_from_cstring (interp , value , encoding );
50
71
}
51
72
52
73
static STRING * get_str (PARROT_INTERP , STable * st , void * data ) {
@@ -74,7 +95,7 @@ static STRING *get_str(PARROT_INTERP, STable *st, void *data) {
74
95
enc_pmc = decontainerize (interp , VTABLE_get_pmc_keyed_int (interp , cappy , 0 ));
75
96
enc = REPR (enc_pmc )-> box_funcs -> get_str (interp , STABLE (enc_pmc ), OBJECT_BODY (enc_pmc ));
76
97
77
- return Parrot_str_new_from_cstring (interp , body -> cstr , enc );
98
+ return new_from_cstring (interp , body -> cstr , enc );
78
99
}
79
100
80
101
/* Creates a new type object of this representation, and associates it with
0 commit comments