Skip to content

Instantly share code, notes, and snippets.

@yawaramin
yawaramin / unicode_example.ml
Last active August 26, 2023 13:44
Example of encoding Unicode graphemes as string and taking its length
(* Re: https://twitter.com/llaisdy/status/1558536851560054786?s=20&t=us8J3LvoJTlwVwod5bOqeQ *)
(* Use this if using the REPL, otherwise use dune to build with the library dependency *)
#require "uutf";;
(* Converts an array of ints (Unicode graphemes) into a UTF-8 encoded string. *)
let utf8_to_string uchars =
let buf = Buffer.create (2 * Array.length uchars) in
Array.iter (fun uchar -> Uutf.Buffer.add_utf_8 buf (Uchar.of_int uchar)) uchars;
Buffer.contents buf
@zr-tex8r
zr-tex8r / pxbabel-up-otf.sty
Last active July 1, 2026 16:45
LaTeX: To make the combination upLaTeX + otf + pxbabel work
% upLaTeX での pxbabel はCJK言語の切替を
% J20,J21,J22,J23,J30,J31,J32,J33
% という"和文エンコーディング"の切替で実現している.
% これらのエンコーディングに対応する和文フォントは
% pLaTeX の既定である mc, gt のファミリにのみ提供される.
%
% 一方で, otf パッケージ(noreplace非指定)は, 和文の
% 総称ファミリの既定値(\mcdefault/\gtdefault)を
% "hmc"/"hgt" に変更する.
% 日本語の種々の"素敵な"フォントはこのファミリに