strutilascii.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. /*
  2. ASCII strings utilities
  3. Copyright (C) 2007-2024
  4. Free Software Foundation, Inc.
  5. Written by:
  6. Rostislav Benes, 2007
  7. This file is part of the Midnight Commander.
  8. The Midnight Commander is free software: you can redistribute it
  9. and/or modify it under the terms of the GNU General Public License as
  10. published by the Free Software Foundation, either version 3 of the License,
  11. or (at your option) any later version.
  12. The Midnight Commander is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <config.h>
  20. #include <ctype.h>
  21. #include <stdlib.h>
  22. #include "lib/global.h"
  23. #include "lib/strutil.h"
  24. /* using g_ascii function from glib
  25. * on terminal are showed only ascii characters (lower than 0x80)
  26. */
  27. /*** global variables ****************************************************************************/
  28. /*** file scope macro definitions ****************************************************************/
  29. /*** file scope type declarations ****************************************************************/
  30. /*** forward declarations (file scope functions) *************************************************/
  31. /*** file scope variables ************************************************************************/
  32. static const char replch = '?';
  33. /* --------------------------------------------------------------------------------------------- */
  34. /*** file scope functions ************************************************************************/
  35. /* --------------------------------------------------------------------------------------------- */
  36. static void
  37. str_ascii_insert_replace_char (GString *buffer)
  38. {
  39. g_string_append_c (buffer, replch);
  40. }
  41. /* --------------------------------------------------------------------------------------------- */
  42. static gboolean
  43. str_ascii_is_valid_string (const char *text)
  44. {
  45. (void) text;
  46. return TRUE;
  47. }
  48. /* --------------------------------------------------------------------------------------------- */
  49. static int
  50. str_ascii_is_valid_char (const char *ch, size_t size)
  51. {
  52. (void) ch;
  53. (void) size;
  54. return 1;
  55. }
  56. /* --------------------------------------------------------------------------------------------- */
  57. static void
  58. str_ascii_cnext_char (const char **text)
  59. {
  60. (*text)++;
  61. }
  62. /* --------------------------------------------------------------------------------------------- */
  63. static void
  64. str_ascii_cprev_char (const char **text)
  65. {
  66. (*text)--;
  67. }
  68. /* --------------------------------------------------------------------------------------------- */
  69. static int
  70. str_ascii_cnext_noncomb_char (const char **text)
  71. {
  72. if (*text[0] == '\0')
  73. return 0;
  74. (*text)++;
  75. return 1;
  76. }
  77. /* --------------------------------------------------------------------------------------------- */
  78. static int
  79. str_ascii_cprev_noncomb_char (const char **text, const char *begin)
  80. {
  81. if ((*text) == begin)
  82. return 0;
  83. (*text)--;
  84. return 1;
  85. }
  86. /* --------------------------------------------------------------------------------------------- */
  87. static gboolean
  88. str_ascii_isspace (const char *text)
  89. {
  90. return g_ascii_isspace ((gchar) text[0]);
  91. }
  92. /* --------------------------------------------------------------------------------------------- */
  93. static gboolean
  94. str_ascii_ispunct (const char *text)
  95. {
  96. return g_ascii_ispunct ((gchar) text[0]);
  97. }
  98. /* --------------------------------------------------------------------------------------------- */
  99. static gboolean
  100. str_ascii_isalnum (const char *text)
  101. {
  102. return g_ascii_isalnum ((gchar) text[0]);
  103. }
  104. /* --------------------------------------------------------------------------------------------- */
  105. static gboolean
  106. str_ascii_isdigit (const char *text)
  107. {
  108. return g_ascii_isdigit ((gchar) text[0]);
  109. }
  110. /* --------------------------------------------------------------------------------------------- */
  111. static gboolean
  112. str_ascii_isprint (const char *text)
  113. {
  114. return g_ascii_isprint ((gchar) text[0]);
  115. }
  116. /* --------------------------------------------------------------------------------------------- */
  117. static gboolean
  118. str_ascii_iscombiningmark (const char *text)
  119. {
  120. (void) text;
  121. return FALSE;
  122. }
  123. /* --------------------------------------------------------------------------------------------- */
  124. static int
  125. str_ascii_toupper (const char *text, char **out, size_t *remain)
  126. {
  127. if (*remain <= 1)
  128. return FALSE;
  129. (*out)[0] = (char) g_ascii_toupper ((gchar) text[0]);
  130. (*out)++;
  131. (*remain)--;
  132. return TRUE;
  133. }
  134. /* --------------------------------------------------------------------------------------------- */
  135. static gboolean
  136. str_ascii_tolower (const char *text, char **out, size_t *remain)
  137. {
  138. if (*remain <= 1)
  139. return FALSE;
  140. (*out)[0] = (char) g_ascii_tolower ((gchar) text[0]);
  141. (*out)++;
  142. (*remain)--;
  143. return TRUE;
  144. }
  145. /* --------------------------------------------------------------------------------------------- */
  146. static int
  147. str_ascii_length (const char *text)
  148. {
  149. return strlen (text);
  150. }
  151. /* --------------------------------------------------------------------------------------------- */
  152. static int
  153. str_ascii_length2 (const char *text, int size)
  154. {
  155. return (size >= 0) ? MIN (strlen (text), (gsize) size) : strlen (text);
  156. }
  157. /* --------------------------------------------------------------------------------------------- */
  158. static gchar *
  159. str_ascii_conv_gerror_message (GError *mcerror, const char *def_msg)
  160. {
  161. /* the same as str_utf8_conv_gerror_message() */
  162. if (mcerror != NULL)
  163. return g_strdup (mcerror->message);
  164. return g_strdup (def_msg != NULL ? def_msg : "");
  165. }
  166. /* --------------------------------------------------------------------------------------------- */
  167. static estr_t
  168. str_ascii_vfs_convert_to (GIConv coder, const char *string, int size, GString *buffer)
  169. {
  170. (void) coder;
  171. g_string_append_len (buffer, string, size);
  172. return ESTR_SUCCESS;
  173. }
  174. /* --------------------------------------------------------------------------------------------- */
  175. static const char *
  176. str_ascii_term_form (const char *text)
  177. {
  178. static char result[BUF_MEDIUM];
  179. char *actual;
  180. size_t remain;
  181. size_t length;
  182. size_t pos = 0;
  183. actual = result;
  184. remain = sizeof (result);
  185. length = strlen (text);
  186. /* go throw all characters and check, if they are ascii and printable */
  187. for (; pos < length && remain > 1; pos++, actual++, remain--)
  188. {
  189. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  190. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  191. }
  192. actual[0] = '\0';
  193. return result;
  194. }
  195. /* --------------------------------------------------------------------------------------------- */
  196. static const char *
  197. str_ascii_fit_to_term (const char *text, int width, align_crt_t just_mode)
  198. {
  199. static char result[BUF_MEDIUM];
  200. char *actual;
  201. size_t remain;
  202. int ident = 0;
  203. size_t length;
  204. size_t pos = 0;
  205. length = strlen (text);
  206. actual = result;
  207. remain = sizeof (result);
  208. if ((int) length <= width)
  209. {
  210. switch (HIDE_FIT (just_mode))
  211. {
  212. case J_CENTER_LEFT:
  213. case J_CENTER:
  214. ident = (width - length) / 2;
  215. break;
  216. case J_RIGHT:
  217. ident = width - length;
  218. break;
  219. default:
  220. break;
  221. }
  222. /* add space before text */
  223. if ((int) remain <= ident)
  224. goto finally;
  225. memset (actual, ' ', ident);
  226. actual += ident;
  227. remain -= ident;
  228. /* copy all characters */
  229. for (; pos < (gsize) length && remain > 1; pos++, actual++, remain--)
  230. {
  231. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  232. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  233. }
  234. /* add space after text */
  235. if (width - length - ident > 0)
  236. {
  237. if (remain <= width - length - ident)
  238. goto finally;
  239. memset (actual, ' ', width - length - ident);
  240. actual += width - length - ident;
  241. }
  242. }
  243. else if (IS_FIT (just_mode))
  244. {
  245. /* copy prefix of text, that is not wider than width / 2 */
  246. for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
  247. {
  248. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  249. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  250. }
  251. if (remain <= 1)
  252. goto finally;
  253. actual[0] = '~';
  254. actual++;
  255. remain--;
  256. pos += length - width + 1;
  257. /* copy suffix of text */
  258. for (; pos < length && remain > 1; pos++, actual++, remain--)
  259. {
  260. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  261. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  262. }
  263. }
  264. else
  265. {
  266. switch (HIDE_FIT (just_mode))
  267. {
  268. case J_CENTER:
  269. ident = (length - width) / 2;
  270. break;
  271. case J_RIGHT:
  272. ident = length - width;
  273. break;
  274. default:
  275. break;
  276. }
  277. /* copy substring text, substring start from ident and take width
  278. * characters from text */
  279. pos += ident;
  280. for (; pos < (gsize) (ident + width) && remain > 1; pos++, actual++, remain--)
  281. {
  282. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  283. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  284. }
  285. }
  286. finally:
  287. if (actual >= result + sizeof (result))
  288. actual = result + sizeof (result) - 1;
  289. actual[0] = '\0';
  290. return result;
  291. }
  292. /* --------------------------------------------------------------------------------------------- */
  293. static const char *
  294. str_ascii_term_trim (const char *text, int width)
  295. {
  296. static char result[BUF_MEDIUM];
  297. size_t remain;
  298. char *actual;
  299. size_t length;
  300. length = strlen (text);
  301. actual = result;
  302. remain = sizeof (result);
  303. if (width > 0)
  304. {
  305. size_t pos;
  306. if (width >= (int) length)
  307. {
  308. /* copy all characters */
  309. for (pos = 0; pos < length && remain > 1; pos++, actual++, remain--)
  310. {
  311. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  312. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  313. }
  314. }
  315. else if (width <= 3)
  316. {
  317. memset (actual, '.', width);
  318. actual += width;
  319. }
  320. else
  321. {
  322. memset (actual, '.', 3);
  323. actual += 3;
  324. remain -= 3;
  325. /* copy suffix of text */
  326. for (pos = length - width + 3; pos < length && remain > 1; pos++, actual++, remain--)
  327. {
  328. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  329. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  330. }
  331. }
  332. }
  333. actual[0] = '\0';
  334. return result;
  335. }
  336. /* --------------------------------------------------------------------------------------------- */
  337. static int
  338. str_ascii_term_width2 (const char *text, size_t length)
  339. {
  340. return (length != (size_t) (-1)) ? MIN (strlen (text), length) : strlen (text);
  341. }
  342. /* --------------------------------------------------------------------------------------------- */
  343. static int
  344. str_ascii_term_width1 (const char *text)
  345. {
  346. return str_ascii_term_width2 (text, (size_t) (-1));
  347. }
  348. /* --------------------------------------------------------------------------------------------- */
  349. static int
  350. str_ascii_term_char_width (const char *text)
  351. {
  352. (void) text;
  353. return 1;
  354. }
  355. /* --------------------------------------------------------------------------------------------- */
  356. static const char *
  357. str_ascii_term_substring (const char *text, int start, int width)
  358. {
  359. static char result[BUF_MEDIUM];
  360. size_t remain;
  361. char *actual;
  362. size_t length;
  363. actual = result;
  364. remain = sizeof (result);
  365. length = strlen (text);
  366. if (start < (int) length)
  367. {
  368. size_t pos;
  369. /* copy at most width characters from text from start */
  370. for (pos = start; pos < length && width > 0 && remain > 1;
  371. pos++, width--, actual++, remain--)
  372. {
  373. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  374. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  375. }
  376. }
  377. /* if text is shorter then width, add space to the end */
  378. for (; width > 0 && remain > 1; actual++, remain--, width--)
  379. actual[0] = ' ';
  380. actual[0] = '\0';
  381. return result;
  382. }
  383. /* --------------------------------------------------------------------------------------------- */
  384. static const char *
  385. str_ascii_trunc (const char *text, int width)
  386. {
  387. static char result[MC_MAXPATHLEN];
  388. int remain;
  389. char *actual;
  390. size_t pos = 0;
  391. size_t length;
  392. actual = result;
  393. remain = sizeof (result);
  394. length = strlen (text);
  395. if ((int) length > width)
  396. {
  397. /* copy prefix of text */
  398. for (; pos + 1 <= (gsize) width / 2 && remain > 1; actual++, pos++, remain--)
  399. {
  400. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  401. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  402. }
  403. if (remain <= 1)
  404. goto finally;
  405. actual[0] = '~';
  406. actual++;
  407. remain--;
  408. pos += length - width + 1;
  409. /* copy suffix of text */
  410. for (; pos < length && remain > 1; pos++, actual++, remain--)
  411. {
  412. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  413. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  414. }
  415. }
  416. else
  417. {
  418. /* copy all characters */
  419. for (; pos < length && remain > 1; pos++, actual++, remain--)
  420. {
  421. actual[0] = isascii ((unsigned char) text[pos]) ? text[pos] : '?';
  422. actual[0] = g_ascii_isprint ((gchar) actual[0]) ? actual[0] : '.';
  423. }
  424. }
  425. finally:
  426. actual[0] = '\0';
  427. return result;
  428. }
  429. /* --------------------------------------------------------------------------------------------- */
  430. static int
  431. str_ascii_offset_to_pos (const char *text, size_t length)
  432. {
  433. (void) text;
  434. return (int) length;
  435. }
  436. /* --------------------------------------------------------------------------------------------- */
  437. static int
  438. str_ascii_column_to_pos (const char *text, size_t pos)
  439. {
  440. (void) text;
  441. return (int) pos;
  442. }
  443. /* --------------------------------------------------------------------------------------------- */
  444. static char *
  445. str_ascii_create_search_needle (const char *needle, gboolean case_sen)
  446. {
  447. (void) case_sen;
  448. return (char *) needle;
  449. }
  450. /* --------------------------------------------------------------------------------------------- */
  451. static void
  452. str_ascii_release_search_needle (char *needle, gboolean case_sen)
  453. {
  454. (void) case_sen;
  455. (void) needle;
  456. }
  457. /* --------------------------------------------------------------------------------------------- */
  458. static const char *
  459. str_ascii_search_first (const char *text, const char *search, gboolean case_sen)
  460. {
  461. char *fold_text;
  462. char *fold_search;
  463. const char *match;
  464. fold_text = case_sen ? (char *) text : g_ascii_strdown (text, -1);
  465. fold_search = case_sen ? (char *) search : g_ascii_strdown (search, -1);
  466. match = g_strstr_len (fold_text, -1, fold_search);
  467. if (match != NULL)
  468. {
  469. size_t offset;
  470. offset = match - fold_text;
  471. match = text + offset;
  472. }
  473. if (!case_sen)
  474. {
  475. g_free (fold_text);
  476. g_free (fold_search);
  477. }
  478. return match;
  479. }
  480. /* --------------------------------------------------------------------------------------------- */
  481. static const char *
  482. str_ascii_search_last (const char *text, const char *search, gboolean case_sen)
  483. {
  484. char *fold_text;
  485. char *fold_search;
  486. const char *match;
  487. fold_text = case_sen ? (char *) text : g_ascii_strdown (text, -1);
  488. fold_search = case_sen ? (char *) search : g_ascii_strdown (search, -1);
  489. match = g_strrstr_len (fold_text, -1, fold_search);
  490. if (match != NULL)
  491. {
  492. size_t offset;
  493. offset = match - fold_text;
  494. match = text + offset;
  495. }
  496. if (!case_sen)
  497. {
  498. g_free (fold_text);
  499. g_free (fold_search);
  500. }
  501. return match;
  502. }
  503. /* --------------------------------------------------------------------------------------------- */
  504. static int
  505. str_ascii_compare (const char *t1, const char *t2)
  506. {
  507. return strcmp (t1, t2);
  508. }
  509. /* --------------------------------------------------------------------------------------------- */
  510. static int
  511. str_ascii_ncompare (const char *t1, const char *t2)
  512. {
  513. return strncmp (t1, t2, MIN (strlen (t1), strlen (t2)));
  514. }
  515. /* --------------------------------------------------------------------------------------------- */
  516. static int
  517. str_ascii_casecmp (const char *t1, const char *t2)
  518. {
  519. return g_ascii_strcasecmp (t1, t2);
  520. }
  521. /* --------------------------------------------------------------------------------------------- */
  522. static int
  523. str_ascii_ncasecmp (const char *t1, const char *t2)
  524. {
  525. return g_ascii_strncasecmp (t1, t2, MIN (strlen (t1), strlen (t2)));
  526. }
  527. /* --------------------------------------------------------------------------------------------- */
  528. static void
  529. str_ascii_fix_string (char *text)
  530. {
  531. for (; text[0] != '\0'; text++)
  532. text[0] = ((unsigned char) text[0] < 128) ? text[0] : '?';
  533. }
  534. /* --------------------------------------------------------------------------------------------- */
  535. static char *
  536. str_ascii_create_key (const char *text, gboolean case_sen)
  537. {
  538. (void) case_sen;
  539. return (char *) text;
  540. }
  541. /* --------------------------------------------------------------------------------------------- */
  542. static int
  543. str_ascii_key_collate (const char *t1, const char *t2, gboolean case_sen)
  544. {
  545. return case_sen ? strcmp (t1, t2) : g_ascii_strcasecmp (t1, t2);
  546. }
  547. /* --------------------------------------------------------------------------------------------- */
  548. static void
  549. str_ascii_release_key (char *key, gboolean case_sen)
  550. {
  551. (void) key;
  552. (void) case_sen;
  553. }
  554. /* --------------------------------------------------------------------------------------------- */
  555. static int
  556. str_ascii_prefix (const char *text, const char *prefix)
  557. {
  558. int result;
  559. for (result = 0;
  560. text[result] != '\0' && prefix[result] != '\0' && text[result] == prefix[result]; result++)
  561. ;
  562. return result;
  563. }
  564. /* --------------------------------------------------------------------------------------------- */
  565. static int
  566. str_ascii_caseprefix (const char *text, const char *prefix)
  567. {
  568. int result;
  569. for (result = 0; text[result] != '\0' && prefix[result] != '\0'
  570. && g_ascii_toupper (text[result]) == g_ascii_toupper (prefix[result]);
  571. result++)
  572. ;
  573. return result;
  574. }
  575. /* --------------------------------------------------------------------------------------------- */
  576. /*** public functions ****************************************************************************/
  577. /* --------------------------------------------------------------------------------------------- */
  578. struct str_class
  579. str_ascii_init (void)
  580. {
  581. struct str_class result;
  582. result.conv_gerror_message = str_ascii_conv_gerror_message;
  583. result.vfs_convert_to = str_ascii_vfs_convert_to;
  584. result.insert_replace_char = str_ascii_insert_replace_char;
  585. result.is_valid_string = str_ascii_is_valid_string;
  586. result.is_valid_char = str_ascii_is_valid_char;
  587. result.cnext_char = str_ascii_cnext_char;
  588. result.cprev_char = str_ascii_cprev_char;
  589. result.cnext_char_safe = str_ascii_cnext_char;
  590. result.cprev_char_safe = str_ascii_cprev_char;
  591. result.cnext_noncomb_char = str_ascii_cnext_noncomb_char;
  592. result.cprev_noncomb_char = str_ascii_cprev_noncomb_char;
  593. result.char_isspace = str_ascii_isspace;
  594. result.char_ispunct = str_ascii_ispunct;
  595. result.char_isalnum = str_ascii_isalnum;
  596. result.char_isdigit = str_ascii_isdigit;
  597. result.char_isprint = str_ascii_isprint;
  598. result.char_iscombiningmark = str_ascii_iscombiningmark;
  599. result.char_toupper = str_ascii_toupper;
  600. result.char_tolower = str_ascii_tolower;
  601. result.length = str_ascii_length;
  602. result.length2 = str_ascii_length2;
  603. result.length_noncomb = str_ascii_length;
  604. result.fix_string = str_ascii_fix_string;
  605. result.term_form = str_ascii_term_form;
  606. result.fit_to_term = str_ascii_fit_to_term;
  607. result.term_trim = str_ascii_term_trim;
  608. result.term_width2 = str_ascii_term_width2;
  609. result.term_width1 = str_ascii_term_width1;
  610. result.term_char_width = str_ascii_term_char_width;
  611. result.term_substring = str_ascii_term_substring;
  612. result.trunc = str_ascii_trunc;
  613. result.offset_to_pos = str_ascii_offset_to_pos;
  614. result.column_to_pos = str_ascii_column_to_pos;
  615. result.create_search_needle = str_ascii_create_search_needle;
  616. result.release_search_needle = str_ascii_release_search_needle;
  617. result.search_first = str_ascii_search_first;
  618. result.search_last = str_ascii_search_last;
  619. result.compare = str_ascii_compare;
  620. result.ncompare = str_ascii_ncompare;
  621. result.casecmp = str_ascii_casecmp;
  622. result.ncasecmp = str_ascii_ncasecmp;
  623. result.prefix = str_ascii_prefix;
  624. result.caseprefix = str_ascii_caseprefix;
  625. result.create_key = str_ascii_create_key;
  626. result.create_key_for_filename = str_ascii_create_key;
  627. result.key_collate = str_ascii_key_collate;
  628. result.release_key = str_ascii_release_key;
  629. return result;
  630. }
  631. /* --------------------------------------------------------------------------------------------- */