help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generate random char (and string) from unicode category (e.g: letter


From: Eli Zaretskii
Subject: Re: Generate random char (and string) from unicode category (e.g: letter)
Date: Thu, 06 Dec 2018 13:24:00 +0200

> From: Alexandre Garreau <galex-713@galex-713.eu>
> Date: Thu, 06 Dec 2018 11:44:38 +0100
> 
> #+BEGIN_SRC emacs-lisp
> (defun random-letter (&rest osef)
>   (let ((num (random (max-char))))
>     (until (string-match "[[:alpha:]]" (string num))
>       (setq num (random (max-char))))
>     num))
> #+END_SRC
> 
> and use it like this:
> 
> #+BEGIN_SRC emacs-lisp
> (apply #'string (mapcar #'random-letter (make-list (1+ (random 190)) nil)))
> #+END_SRC
> 
> Problems is I get stuff like this: "䯩繩ꏴ跾ಾ𢉰𐎕𘓅𪆶矏ᄬ𣒈⳰𨜄𛰸𧅌煂𢙴𧐁𡚯
> 𦅉ᤋ𡇼钇꿚㱓㗧𩅍姵爠𣑽𠌤ꇊ𡘄𑄇𫲘𪯋𣊚𦉂𠦵𘕋𠈾ლ𨟇𦷕𤃻𫿡𢿟巙𩿊𥖠𒒈ባ𗆘𤧟𗲀𔗸𖼂뺔
> 𧸋𡠜𬶟咨발𬞗쏊紋䲁坮𠢥旼𗴟𬓏𤁍គ𩍏Ɉ𪅊𤙬𫪃𫴛𤶋𫴃𧐨䞪𩇨𡤦馲𨂧𡮃𓂅𒇵𤉴𥙯藣ბ솇
> 𨆬𦄎靔𐤒ඐ𒐕襋𬵝𥤄𪃝𫈹𨣼𘋹돃𪣞筛𣯿휈𥽊Ꭾ𣐧𥺒𠊆ꮩ闭ઉ𦻸𨔆𤛢𢮁𤟩𪊕𥫰𪢟𡻋𘅇ᶗ펙𣄽
> 玽쭻𩿎𗔥𪟉䪁ᣃ쒝𩅑𡞬넒煮ڒꫥ𥾴𣁫𬑼깙𣫖筁ᣯ𣱮𡡯𨐒ﶒ𤑳𤯼昵䊘㝓𣑼𐦥𥆤갛𤡇𠜠𥉡䋯𥫻
> 𪲩兀𖠹瀖𣊫𨘥𢍪ᴢ", where the majority of characters are non-displayable
> and are shown with a square with numbers in it to indicate there’s
> nothing such that in installed fonts.  I clearly recall I what I did
> there were no such characters, so something must be possible (maybe
> using charsets?).

If you don't want characters that need fancy fonts, why do you use
max-char?  Why not a smaller value, like 255?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]