diff options
author | Colin Leroy-Mira <colin@colino.net> | 2023-08-29 08:02:50 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2023-08-29 09:31:23 +0200 |
commit | dfe8c445883a50a55564b02b6957257bfc510db4 (patch) | |
tree | fcd0e0cdce35897c7c0efb94f8c7d54f0ab46377 /localedata | |
parent | c00b984fcd53f679ca2dafcd1aee2c89836e6e73 (diff) | |
download | glibc-dfe8c445883a50a55564b02b6957257bfc510db4.tar glibc-dfe8c445883a50a55564b02b6957257bfc510db4.tar.gz glibc-dfe8c445883a50a55564b02b6957257bfc510db4.tar.bz2 glibc-dfe8c445883a50a55564b02b6957257bfc510db4.zip |
localedata: Translit common emojis to smileys [BZ #30649]
Add common emojis to the translit-able characters (mostly
faces and hearts), and translit them to old-fashioned
smileys.
Signed-off-by: Colin Leroy-Mira <colin@colino.net>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Diffstat (limited to 'localedata')
-rw-r--r-- | localedata/Makefile | 4 | ||||
-rw-r--r-- | localedata/locales/translit_emojis | 91 | ||||
-rw-r--r-- | localedata/locales/translit_neutral | 1 | ||||
-rw-r--r-- | localedata/tst-iconv-emojis-trans.c | 117 |
4 files changed, 213 insertions, 0 deletions
diff --git a/localedata/Makefile b/localedata/Makefile index 3619b6d47e..dd41db6d8f 100644 --- a/localedata/Makefile +++ b/localedata/Makefile @@ -1,4 +1,5 @@ # Copyright (C) 1996-2023 Free Software Foundation, Inc. +# Copyright The GNU Toolchain Authors. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -164,6 +165,7 @@ tests = \ bug-usesetlocale \ tst-c-utf8-consistency \ tst-digits \ + tst-iconv-emojis-trans \ tst-iconv-math-trans \ tst-leaks \ tst-mbswcs1 \ @@ -320,6 +322,8 @@ LOCALES := \ include ../gen-locales.mk +$(objpfx)tst-iconv-emojis-trans.out: $(gen-locales) + $(objpfx)tst-iconv-math-trans.out: $(gen-locales) endif diff --git a/localedata/locales/translit_emojis b/localedata/locales/translit_emojis new file mode 100644 index 0000000000..cfb1964afa --- /dev/null +++ b/localedata/locales/translit_emojis @@ -0,0 +1,91 @@ +escape_char / +comment_char % + +% This file is part of the GNU C Library and contains locale data. +% The Free Software Foundation and the GNU Toolchain Authors do not +% claim any copyright interest in the locale data contained in this +% file. The foregoing does not affect the license of the GNU C +% Library as a whole. It does not exempt you from the conditions +% of the license if your use would otherwise be governed by that +% license. + +% Transliterations of emojis to ASCII smileys. + +LC_CTYPE + +translit_start + +โก "/<3" % WHITE HEART SUIT +โฅ "/<3" % BLACK HEART SUIT +โค "/<3" % HEAVY BLACK HEART +๐ "/<3" % BLUE HEART +๐ "/<3" % BEATING HEART +๐ "/<//3" % BROKEN HEART +๐ "/<3" % SPARKLING HEART +๐ "/<3" % GROWING HEART +๐ "/<3" % GREEN HEART +๐ "/<3" % YELLOW HEART +๐ "/<3" % PURPLE HEART +๐ค "/<3" % BLACK HEART +๐งก "/<3" % ORANGE HEART +๐ค "/<3" % WHITE HEART +๐ค "/<3" % BROWN HEART +๐ ":-D" % GRINNING FACE +๐ ":-D" % GRINNING FACE WITH SMILING EYES +๐ ":'D" % FACE WITH TEARS OF JOY +๐ ":-D" % SMILING FACE WITH OPEN MOUTH (C.F. โบ) +๐ ":-D" % SMILING FACE WITH OPEN MOUTH AND SMILING EYES +๐
":-D" % SMILING FACE WITH OPEN MOUTH AND COLD SWEAT +๐ ":-D" % SMILING FACE WITH OPEN MOUTH AND TIGHTLY-CLOSED EYES +๐ "O:-)" % SMILING FACE WITH HALO +๐ "/>:)" % SMILING FACE WITH HORNS +๐ ";-)" % WINKING FACE +๐ ":-)" % SMILING FACE WITH SMILING EYES +๐ ":-P" % FACE SAVOURING DELICIOUS FOOD +๐ ":-)" % RELIEVED FACE +๐ ":-*" % SMILING FACE WITH HEART-SHAPED EYES +๐ "B-)" % SMILING FACE WITH SUNGLASSES +๐ ";-)" % SMIRKING FACE +๐ ":-|" % NEUTRAL FACE +๐ ":-|" % EXPRESSIONLESS FACE +๐ ":-|" % UNAMUSED FACE +๐ ":'-|" % FACE WITH COLD SWEAT +๐ ":-|" % PENSIVE FACE +๐ ":-//" % CONFUSED FACE +๐ ":-S" % CONFOUNDED FACE +๐ ":-*" % KISSING FACE +๐ ":-*" % FACE THROWING A KISS +๐ ":-*" % KISSING FACE WITH SMILING EYES +๐ ":-*" % KISSING FACE WITH CLOSED EYES +๐ ":-P" % FACE WITH STUCK-OUT TONGUE +๐ ";-P" % FACE WITH STUCK-OUT TONGUE AND WINKING EYE +๐ "X-P" % FACE WITH STUCK-OUT TONGUE AND TIGHTLY-CLOSED EYES +๐ ":-(" % DISAPPOINTED FACE +๐ ":-(" % WORRIED FACE +๐ "/>:-(" % ANGRY FACE +๐ก ":-(" % POUTING FACE +๐ข ":'-(" % CRYING FACE +๐ฃ "X-(" % PERSEVERING FACE +๐ฆ ":-O" % FROWNING FACE WITH OPEN MOUTH +๐ง ":-O" % ANGUISHED FACE +๐จ ":-O" % FEARFUL FACE +๐ฉ ":-O" % WEARY FACE +๐ญ ":<U0022>-(" % LOUDLY CRYING FACE +๐ฎ ":-O" % FACE WITH OPEN MOUTH +๐ฏ ":-O" % HUSHED FACE +๐ฐ ":'-O" % FACE WITH OPEN MOUTH AND COLD SWEAT +๐ฑ ":-O" % FACE SCREAMING IN FEAR +๐ฒ ":-O" % ASTONISHED FACE +๐ธ ":-3" % GRINNING CAT FACE WITH SMILING EYES +๐น ":'-3" % CAT FACE WITH TEARS OF JOY +๐บ ":-3" % SMILING CAT FACE WITH OPEN MOUTH +๐ป ":-3" % SMILING CAT FACE WITH HEART-SHAPE EYES +๐ผ ";-3" % CAT FACE WITH WRY SMILE +๐ฝ ":-3" % KISSING CAT FACE WITH CLOSED EYES +๐ ":-(" % SLIGHTLY FROWNING FACE +๐ ":-)" % SLIGHTLY SMILING FACE +๐ "(-:" % UPSIDE-DOWN FACE + +translit_end + +END LC_CTYPE diff --git a/localedata/locales/translit_neutral b/localedata/locales/translit_neutral index 72f66220b7..57412ae565 100644 --- a/localedata/locales/translit_neutral +++ b/localedata/locales/translit_neutral @@ -17,6 +17,7 @@ translit_start include "translit_circle";"" include "translit_cjk_compat";"" include "translit_compat";"" +include "translit_emojis";"" include "translit_font";"" include "translit_fraction";"" include "translit_narrow";"" diff --git a/localedata/tst-iconv-emojis-trans.c b/localedata/tst-iconv-emojis-trans.c new file mode 100644 index 0000000000..de4c20a279 --- /dev/null +++ b/localedata/tst-iconv-emojis-trans.c @@ -0,0 +1,117 @@ +/* Test some emoji transliterations + + Copyright (C) 2019-2023 Free Software Foundation, Inc. + Copyright The GNU Toolchain Authors. + + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <iconv.h> +#include <locale.h> +#include <stdio.h> +#include <string.h> +#include <support/check.h> + +static int +do_test (void) +{ + iconv_t cd; + + const int num_emojis = 70; + + const char str[] = "โก โฅ โค ๐ ๐ " + "๐ ๐ ๐ ๐ ๐ " + "๐ ๐ค ๐งก ๐ค ๐ค " + "๐ ๐ ๐ ๐ ๐ " + "๐
๐ ๐ ๐ ๐ " + "๐ ๐ ๐ ๐ ๐ " + "๐ ๐ ๐ ๐ ๐ " + "๐ ๐ ๐ ๐ ๐ " + "๐ ๐ ๐ ๐ ๐ " + "๐ ๐ ๐ ๐ก ๐ข " + "๐ฃ ๐ฆ ๐ง ๐จ ๐ฉ " + "๐ญ ๐ฎ ๐ฏ ๐ฐ ๐ฑ " + "๐ฒ ๐ธ ๐น ๐บ ๐ป " + "๐ผ ๐ฝ ๐ ๐ ๐"; + + const char expected[] = "<3 <3 <3 <3 <3 " + "</3 <3 <3 <3 <3 " + "<3 <3 <3 <3 <3 " + ":-D :-D :'D :-D :-D " + ":-D :-D O:-) >:) ;-) " + ":-) :-P :-) :-* B-) " + ";-) :-| :-| :-| :'-| " + ":-| :-/ :-S :-* :-* " + ":-* :-* :-P ;-P X-P " + ":-( :-( >:-( :-( :'-( " + "X-( :-O :-O :-O :-O " + ":\"-( :-O :-O :'-O :-O " + ":-O :-3 :'-3 :-3 :-3 " + ";-3 :-3 :-( :-) (-:"; + + char *inptr = (char *) str; + size_t inlen = strlen (str) + 1; + char outbuf[500]; + char *outptr = outbuf; + size_t outlen = sizeof (outbuf); + int result = 0; + size_t n; + + if (setlocale (LC_ALL, "en_US.UTF-8") == NULL) + FAIL_EXIT1 ("setlocale failed"); + + cd = iconv_open ("ASCII//TRANSLIT", "UTF-8"); + if (cd == (iconv_t) -1) + FAIL_EXIT1 ("iconv_open failed"); + + n = iconv (cd, &inptr, &inlen, &outptr, &outlen); + if (n != num_emojis) + { + if (n == (size_t) -1) + printf ("iconv() returned error: %m\n"); + else + printf ("iconv() returned %zd, expected %d\n", n, num_emojis); + result = 1; + } + if (inlen != 0) + { + puts ("not all input consumed"); + result = 1; + } + else if (inptr - str != strlen (str) + 1) + { + printf ("inptr wrong, advanced by %td\n", inptr - str); + result = 1; + } + if (memcmp (outbuf, expected, sizeof (expected)) != 0) + { + printf ("result wrong: \"%.*s\", expected: \"%s\"\n", + (int) (sizeof (outbuf) - outlen), outbuf, expected); + result = 1; + } + else if (outlen != sizeof (outbuf) - sizeof (expected)) + { + printf ("outlen wrong: %zd, expected %zd\n", outlen, + sizeof (outbuf) - sizeof (expected)); + result = 1; + } + else + printf ("output is \"%s\" which is OK\n", outbuf); + + return result; +} + +#include <support/test-driver.c> |