2345 |
CODING_SYSTEM, and return a newly allocated memory area which |
CODING_SYSTEM, and return a newly allocated memory area which |
2346 |
should be freed by `xfree' by a caller. |
should be freed by `xfree' by a caller. |
2347 |
|
|
2348 |
|
SELECTIONP non-zero means the string is being encoded for an X |
2349 |
|
selection, so it is safe to run pre-write conversions (which |
2350 |
|
may run Lisp code). |
2351 |
|
|
2352 |
Store the byte length of resulting text in *TEXT_BYTES. |
Store the byte length of resulting text in *TEXT_BYTES. |
2353 |
|
|
2354 |
If the text contains only ASCII and Latin-1, store 1 in *STRING_P, |
If the text contains only ASCII and Latin-1, store 1 in *STRING_P, |
2357 |
the result should be `COMPOUND_TEXT'. */ |
the result should be `COMPOUND_TEXT'. */ |
2358 |
|
|
2359 |
unsigned char * |
unsigned char * |
2360 |
x_encode_text (string, coding_system, text_bytes, stringp) |
x_encode_text (string, coding_system, selectionp, text_bytes, stringp) |
2361 |
Lisp_Object string, coding_system; |
Lisp_Object string, coding_system; |
2362 |
int *text_bytes, *stringp; |
int *text_bytes, *stringp; |
2363 |
|
int selectionp; |
2364 |
{ |
{ |
2365 |
unsigned char *str = XSTRING (string)->data; |
unsigned char *str = XSTRING (string)->data; |
2366 |
int chars = XSTRING (string)->size; |
int chars = XSTRING (string)->size; |
2380 |
} |
} |
2381 |
|
|
2382 |
setup_coding_system (coding_system, &coding); |
setup_coding_system (coding_system, &coding); |
2383 |
|
if (selectionp |
2384 |
|
&& SYMBOLP (coding.pre_write_conversion) |
2385 |
|
&& !NILP (Ffboundp (coding.pre_write_conversion))) |
2386 |
|
{ |
2387 |
|
string = run_pre_post_conversion_on_str (string, &coding, 1); |
2388 |
|
str = XSTRING (string)->data; |
2389 |
|
chars = XSTRING (string)->size; |
2390 |
|
bytes = STRING_BYTES (XSTRING (string)); |
2391 |
|
} |
2392 |
coding.src_multibyte = 1; |
coding.src_multibyte = 1; |
2393 |
coding.dst_multibyte = 0; |
coding.dst_multibyte = 0; |
2394 |
coding.mode |= CODING_MODE_LAST_BLOCK; |
coding.mode |= CODING_MODE_LAST_BLOCK; |
2472 |
coding_system = Vlocale_coding_system; |
coding_system = Vlocale_coding_system; |
2473 |
if (NILP (coding_system)) |
if (NILP (coding_system)) |
2474 |
coding_system = Qcompound_text; |
coding_system = Qcompound_text; |
2475 |
text.value = x_encode_text (name, coding_system, &bytes, &stringp); |
text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); |
2476 |
text.encoding = (stringp ? XA_STRING |
text.encoding = (stringp ? XA_STRING |
2477 |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
2478 |
text.format = 8; |
text.format = 8; |
2484 |
} |
} |
2485 |
else |
else |
2486 |
{ |
{ |
2487 |
icon.value = x_encode_text (f->icon_name, coding_system, |
icon.value = x_encode_text (f->icon_name, coding_system, 0, |
2488 |
&bytes, &stringp); |
&bytes, &stringp); |
2489 |
icon.encoding = (stringp ? XA_STRING |
icon.encoding = (stringp ? XA_STRING |
2490 |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
2579 |
coding_system = Vlocale_coding_system; |
coding_system = Vlocale_coding_system; |
2580 |
if (NILP (coding_system)) |
if (NILP (coding_system)) |
2581 |
coding_system = Qcompound_text; |
coding_system = Qcompound_text; |
2582 |
text.value = x_encode_text (name, coding_system, &bytes, &stringp); |
text.value = x_encode_text (name, coding_system, 0, &bytes, &stringp); |
2583 |
text.encoding = (stringp ? XA_STRING |
text.encoding = (stringp ? XA_STRING |
2584 |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
2585 |
text.format = 8; |
text.format = 8; |
2591 |
} |
} |
2592 |
else |
else |
2593 |
{ |
{ |
2594 |
icon.value = x_encode_text (f->icon_name, coding_system, |
icon.value = x_encode_text (f->icon_name, coding_system, 0, |
2595 |
&bytes, &stringp); |
&bytes, &stringp); |
2596 |
icon.encoding = (stringp ? XA_STRING |
icon.encoding = (stringp ? XA_STRING |
2597 |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |
: FRAME_X_DISPLAY_INFO (f)->Xatom_COMPOUND_TEXT); |