gosu 1.4.6 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. checksums.yaml +4 -4
  2. data/COPYING +2 -1
  3. data/dependencies/SDL/include/SDL3/SDL.h +91 -0
  4. data/dependencies/SDL/include/SDL3/SDL_assert.h +710 -0
  5. data/dependencies/SDL/include/SDL3/SDL_asyncio.h +550 -0
  6. data/dependencies/SDL/include/SDL3/SDL_atomic.h +692 -0
  7. data/dependencies/SDL/include/SDL3/SDL_audio.h +2382 -0
  8. data/dependencies/SDL/include/SDL3/SDL_begin_code.h +553 -0
  9. data/dependencies/SDL/include/{SDL_bits.h → SDL3/SDL_bits.h} +47 -27
  10. data/dependencies/SDL/include/{SDL_blendmode.h → SDL3/SDL_blendmode.h} +59 -55
  11. data/dependencies/SDL/include/SDL3/SDL_camera.h +535 -0
  12. data/dependencies/SDL/include/SDL3/SDL_clipboard.h +331 -0
  13. data/dependencies/SDL/include/{close_code.h → SDL3/SDL_close_code.h} +9 -8
  14. data/dependencies/SDL/include/{SDL_types.h → SDL3/SDL_copying.h} +2 -9
  15. data/dependencies/SDL/include/SDL3/SDL_cpuinfo.h +374 -0
  16. data/dependencies/SDL/include/SDL3/SDL_dialog.h +343 -0
  17. data/dependencies/SDL/include/SDL3/SDL_dlopennote.h +234 -0
  18. data/dependencies/SDL/include/{SDL_egl.h → SDL3/SDL_egl.h} +11 -8
  19. data/dependencies/SDL/include/SDL3/SDL_endian.h +645 -0
  20. data/dependencies/SDL/include/SDL3/SDL_error.h +226 -0
  21. data/dependencies/SDL/include/SDL3/SDL_events.h +1651 -0
  22. data/dependencies/SDL/include/SDL3/SDL_filesystem.h +537 -0
  23. data/dependencies/SDL/include/SDL3/SDL_gamepad.h +1657 -0
  24. data/dependencies/SDL/include/SDL3/SDL_gpu.h +4637 -0
  25. data/dependencies/SDL/include/SDL3/SDL_guid.h +106 -0
  26. data/dependencies/SDL/include/SDL3/SDL_haptic.h +1461 -0
  27. data/dependencies/SDL/include/SDL3/SDL_hidapi.h +571 -0
  28. data/dependencies/SDL/include/SDL3/SDL_hints.h +5041 -0
  29. data/dependencies/SDL/include/SDL3/SDL_init.h +508 -0
  30. data/dependencies/SDL/include/SDL3/SDL_intrin.h +410 -0
  31. data/dependencies/SDL/include/SDL3/SDL_iostream.h +1379 -0
  32. data/dependencies/SDL/include/SDL3/SDL_joystick.h +1385 -0
  33. data/dependencies/SDL/include/SDL3/SDL_keyboard.h +615 -0
  34. data/dependencies/SDL/include/SDL3/SDL_keycode.h +348 -0
  35. data/dependencies/SDL/include/SDL3/SDL_loadso.h +145 -0
  36. data/dependencies/SDL/include/{SDL_locale.h → SDL3/SDL_locale.h} +40 -24
  37. data/dependencies/SDL/include/SDL3/SDL_log.h +541 -0
  38. data/dependencies/SDL/include/SDL3/SDL_main.h +704 -0
  39. data/dependencies/SDL/include/SDL3/SDL_main_impl.h +149 -0
  40. data/dependencies/SDL/include/{SDL_messagebox.h → SDL3/SDL_messagebox.h} +85 -48
  41. data/dependencies/SDL/include/{SDL_metal.h → SDL3/SDL_metal.h} +29 -29
  42. data/dependencies/SDL/include/{SDL_misc.h → SDL3/SDL_misc.h} +13 -12
  43. data/dependencies/SDL/include/SDL3/SDL_mouse.h +813 -0
  44. data/dependencies/SDL/include/SDL3/SDL_mutex.h +1117 -0
  45. data/dependencies/SDL/include/SDL3/SDL_oldnames.h +1339 -0
  46. data/dependencies/SDL/include/{SDL_opengl.h → SDL3/SDL_opengl.h} +1247 -278
  47. data/dependencies/SDL/include/{SDL_opengl_glext.h → SDL3/SDL_opengl_glext.h} +5 -1
  48. data/dependencies/SDL/include/{SDL_opengles.h → SDL3/SDL_opengles.h} +6 -7
  49. data/dependencies/SDL/include/{SDL_opengles2.h → SDL3/SDL_opengles2.h} +10 -11
  50. data/dependencies/SDL/include/SDL3/SDL_pen.h +198 -0
  51. data/dependencies/SDL/include/SDL3/SDL_pixels.h +1441 -0
  52. data/dependencies/SDL/include/{SDL_test_log.h → SDL3/SDL_platform.h} +25 -26
  53. data/dependencies/SDL/include/SDL3/SDL_platform_defines.h +497 -0
  54. data/dependencies/SDL/include/{SDL_power.h → SDL3/SDL_power.h} +40 -20
  55. data/dependencies/SDL/include/SDL3/SDL_process.h +441 -0
  56. data/dependencies/SDL/include/SDL3/SDL_properties.h +572 -0
  57. data/dependencies/SDL/include/SDL3/SDL_rect.h +528 -0
  58. data/dependencies/SDL/include/SDL3/SDL_render.h +3034 -0
  59. data/dependencies/SDL/include/SDL3/SDL_revision.h +56 -0
  60. data/dependencies/SDL/include/{SDL_scancode.h → SDL3/SDL_scancode.h} +60 -68
  61. data/dependencies/SDL/include/SDL3/SDL_sensor.h +321 -0
  62. data/dependencies/SDL/include/SDL3/SDL_stdinc.h +6186 -0
  63. data/dependencies/SDL/include/SDL3/SDL_storage.h +686 -0
  64. data/dependencies/SDL/include/SDL3/SDL_surface.h +1769 -0
  65. data/dependencies/SDL/include/SDL3/SDL_system.h +840 -0
  66. data/dependencies/SDL/include/{SDL_test.h → SDL3/SDL_test.h} +16 -22
  67. data/dependencies/SDL/include/{SDL_test_assert.h → SDL3/SDL_test_assert.h} +27 -34
  68. data/dependencies/SDL/include/{SDL_test_common.h → SDL3/SDL_test_common.h} +109 -52
  69. data/dependencies/SDL/include/{SDL_test_compare.h → SDL3/SDL_test_compare.h} +22 -14
  70. data/dependencies/SDL/include/{SDL_test_crc32.h → SDL3/SDL_test_crc32.h} +27 -30
  71. data/dependencies/SDL/include/{SDL_test_font.h → SDL3/SDL_test_font.h} +50 -49
  72. data/dependencies/SDL/include/{SDL_test_fuzzer.h → SDL3/SDL_test_fuzzer.h} +64 -79
  73. data/dependencies/SDL/include/{SDL_test_harness.h → SDL3/SDL_test_harness.h} +47 -30
  74. data/dependencies/SDL/include/SDL3/SDL_test_log.h +83 -0
  75. data/dependencies/SDL/include/{SDL_test_md5.h → SDL3/SDL_test_md5.h} +21 -28
  76. data/dependencies/SDL/include/{SDL_test_memory.h → SDL3/SDL_test_memory.h} +19 -16
  77. data/dependencies/SDL/include/SDL3/SDL_thread.h +602 -0
  78. data/dependencies/SDL/include/SDL3/SDL_time.h +249 -0
  79. data/dependencies/SDL/include/SDL3/SDL_timer.h +454 -0
  80. data/dependencies/SDL/include/SDL3/SDL_touch.h +184 -0
  81. data/dependencies/SDL/include/SDL3/SDL_tray.h +544 -0
  82. data/dependencies/SDL/include/SDL3/SDL_version.h +198 -0
  83. data/dependencies/SDL/include/SDL3/SDL_video.h +3497 -0
  84. data/dependencies/SDL/include/SDL3/SDL_vulkan.h +287 -0
  85. data/dependencies/SDL/lib/x64/libSDL3.dll.a +0 -0
  86. data/dependencies/SDL/lib/x86/libSDL3.dll.a +0 -0
  87. data/dependencies/SDL_sound/SDL3_sound/SDL_sound.h +755 -0
  88. data/dependencies/SDL_sound/SDL_sound.c +136 -215
  89. data/dependencies/SDL_sound/SDL_sound_aiff.c +55 -54
  90. data/dependencies/SDL_sound/SDL_sound_au.c +32 -32
  91. data/dependencies/SDL_sound/SDL_sound_coreaudio.c +24 -41
  92. data/dependencies/SDL_sound/SDL_sound_flac.c +32 -12
  93. data/dependencies/SDL_sound/SDL_sound_internal.h +33 -48
  94. data/dependencies/SDL_sound/SDL_sound_modplug.c +21 -29
  95. data/dependencies/SDL_sound/SDL_sound_mp3.c +35 -13
  96. data/dependencies/SDL_sound/SDL_sound_raw.c +14 -15
  97. data/dependencies/SDL_sound/SDL_sound_shn.c +82 -82
  98. data/dependencies/SDL_sound/SDL_sound_voc.c +30 -30
  99. data/dependencies/SDL_sound/SDL_sound_vorbis.c +34 -25
  100. data/dependencies/SDL_sound/SDL_sound_wav.c +86 -82
  101. data/dependencies/SDL_sound/dr_flac.h +1890 -1301
  102. data/dependencies/SDL_sound/dr_mp3.h +1098 -660
  103. data/dependencies/SDL_sound/libmodplug/fastmix.c +1 -1
  104. data/dependencies/SDL_sound/libmodplug/libmodplug.h +5 -4
  105. data/dependencies/SDL_sound/libmodplug/load_ams.c +6 -3
  106. data/dependencies/SDL_sound/libmodplug/load_dsm.c +2 -1
  107. data/dependencies/SDL_sound/libmodplug/load_mt2.c +2 -2
  108. data/dependencies/SDL_sound/libmodplug/modplug.h +2 -1
  109. data/dependencies/SDL_sound/libmodplug/snd_fx.c +3 -3
  110. data/dependencies/SDL_sound/libmodplug/sndfile.c +3 -0
  111. data/dependencies/SDL_sound/libmodplug/sndmix.c +7 -3
  112. data/dependencies/SDL_sound/stb_vorbis.h +397 -342
  113. data/dependencies/mojoAL/AL/alc.h +2 -2
  114. data/dependencies/mojoAL/mojoal.c +2120 -1885
  115. data/dependencies/stb/stb_image.h +1190 -1379
  116. data/dependencies/stb/stb_image_write.h +329 -129
  117. data/dependencies/stb/stb_truetype.h +304 -60
  118. data/dependencies/utf8proc/utf8proc.c +133 -75
  119. data/dependencies/utf8proc/utf8proc.h +131 -50
  120. data/dependencies/utf8proc/utf8proc_data.h +16213 -15658
  121. data/ext/gosu-ffi/extconf.rb +103 -0
  122. data/ext/gosu-ffi/gosu-ffi.def +467 -0
  123. data/ffi/Gosu.cpp +330 -0
  124. data/ffi/Gosu.h +84 -0
  125. data/ffi/Gosu_Channel.cpp +62 -0
  126. data/ffi/Gosu_Channel.h +17 -0
  127. data/ffi/Gosu_Color.cpp +176 -0
  128. data/ffi/Gosu_Color.h +31 -0
  129. data/ffi/Gosu_Constants.cpp +334 -0
  130. data/ffi/Gosu_FFI.h +34 -0
  131. data/ffi/Gosu_FFI_internal.h +160 -0
  132. data/ffi/Gosu_Font.cpp +97 -0
  133. data/ffi/Gosu_Font.h +32 -0
  134. data/ffi/Gosu_Image.cpp +239 -0
  135. data/ffi/Gosu_Image.h +71 -0
  136. data/ffi/Gosu_Sample.cpp +29 -0
  137. data/ffi/Gosu_Sample.h +14 -0
  138. data/ffi/Gosu_Song.cpp +69 -0
  139. data/ffi/Gosu_Song.h +18 -0
  140. data/ffi/Gosu_TextInput.cpp +94 -0
  141. data/ffi/Gosu_TextInput.h +25 -0
  142. data/ffi/Gosu_Window.cpp +314 -0
  143. data/ffi/Gosu_Window.h +78 -0
  144. data/include/Gosu/Audio.hpp +6 -11
  145. data/include/Gosu/Bitmap.hpp +38 -53
  146. data/include/Gosu/Buffer.hpp +54 -0
  147. data/include/Gosu/Color.hpp +29 -36
  148. data/include/Gosu/Directories.hpp +25 -28
  149. data/include/Gosu/Drawable.hpp +58 -0
  150. data/include/Gosu/Font.hpp +6 -5
  151. data/include/Gosu/Fwd.hpp +4 -6
  152. data/include/Gosu/Gosu.hpp +5 -5
  153. data/include/Gosu/Graphics.hpp +53 -61
  154. data/include/Gosu/GraphicsBase.hpp +1 -11
  155. data/include/Gosu/Image.hpp +12 -15
  156. data/include/Gosu/Math.hpp +50 -72
  157. data/include/Gosu/Transform.hpp +32 -0
  158. data/include/Gosu/Utility.hpp +77 -1
  159. data/include/Gosu/Version.hpp +2 -2
  160. data/include/Gosu/Window.hpp +15 -9
  161. data/lib/SDL3.dll +0 -0
  162. data/lib/gosu/channel.rb +50 -0
  163. data/lib/gosu/color.rb +173 -0
  164. data/lib/gosu/compat.rb +130 -17
  165. data/lib/gosu/constants.rb +386 -0
  166. data/lib/gosu/ffi.rb +269 -0
  167. data/lib/gosu/font.rb +62 -0
  168. data/lib/gosu/gl_tex_info.rb +33 -0
  169. data/lib/gosu/gosu.rb +250 -0
  170. data/lib/gosu/image.rb +179 -0
  171. data/lib/gosu/numeric.rb +17 -0
  172. data/lib/gosu/preview.rb +6 -6
  173. data/lib/gosu/sample.rb +25 -0
  174. data/lib/gosu/song.rb +57 -0
  175. data/lib/gosu/text_input.rb +83 -0
  176. data/lib/gosu/window.rb +249 -0
  177. data/lib/gosu.rb +29 -8
  178. data/lib64/SDL3.dll +0 -0
  179. data/rdoc/gosu.rb +2 -2
  180. data/src/Audio.cpp +30 -24
  181. data/src/AudioFile.hpp +5 -4
  182. data/src/AudioFileAudioToolbox.cpp +8 -8
  183. data/src/AudioFileSDLSound.cpp +12 -15
  184. data/src/BinPacker.cpp +188 -0
  185. data/src/BinPacker.hpp +55 -0
  186. data/src/Bitmap.cpp +172 -143
  187. data/src/BitmapIO.cpp +60 -86
  188. data/src/Buffer.cpp +150 -0
  189. data/src/ClipRectStack.cpp +38 -0
  190. data/src/ClipRectStack.hpp +17 -83
  191. data/src/Color.cpp +75 -80
  192. data/src/Directories.cpp +47 -0
  193. data/src/DirectoriesUIKit.cpp +50 -0
  194. data/src/DrawOp.hpp +20 -18
  195. data/src/DrawOpQueue.hpp +27 -33
  196. data/src/Drawable.cpp +95 -0
  197. data/src/EmptyDrawable.hpp +38 -0
  198. data/src/FPS.cpp +31 -0
  199. data/src/Font.cpp +104 -74
  200. data/src/GosuGLView.cpp +13 -11
  201. data/src/GosuViewController.cpp +2 -10
  202. data/src/Graphics.cpp +86 -145
  203. data/src/GraphicsImpl.hpp +14 -68
  204. data/src/Image.cpp +41 -35
  205. data/src/Input.cpp +73 -78
  206. data/src/Macro.cpp +46 -29
  207. data/src/Macro.hpp +23 -17
  208. data/src/MarkupParser.cpp +5 -5
  209. data/src/Math.cpp +48 -22
  210. data/src/OffScreenTarget.cpp +47 -50
  211. data/src/OffScreenTarget.hpp +13 -11
  212. data/src/OpenGLContext.cpp +116 -0
  213. data/src/OpenGLContext.hpp +41 -0
  214. data/src/RenderState.hpp +49 -71
  215. data/src/Resolution.cpp +65 -53
  216. data/src/TexChunk.cpp +35 -80
  217. data/src/TexChunk.hpp +44 -35
  218. data/src/Text.cpp +1 -1
  219. data/src/TextBuilder.cpp +35 -21
  220. data/src/TextBuilder.hpp +6 -9
  221. data/src/TextInput.cpp +9 -9
  222. data/src/Texture.cpp +62 -80
  223. data/src/Texture.hpp +25 -23
  224. data/src/TiledDrawable.cpp +149 -0
  225. data/src/TiledDrawable.hpp +47 -0
  226. data/src/TimingApple.cpp +1 -1
  227. data/src/Transform.cpp +45 -50
  228. data/src/TransformStack.hpp +16 -16
  229. data/src/TrueTypeFont.cpp +59 -51
  230. data/src/TrueTypeFont.hpp +6 -7
  231. data/src/TrueTypeFontApple.cpp +28 -19
  232. data/src/TrueTypeFontUnix.cpp +39 -32
  233. data/src/TrueTypeFontWin.cpp +30 -30
  234. data/src/Utility.cpp +113 -37
  235. data/src/UtilityWin.cpp +49 -0
  236. data/src/Window.cpp +121 -151
  237. data/src/WindowUIKit.cpp +14 -14
  238. metadata +165 -118
  239. data/dependencies/SDL/include/SDL.h +0 -233
  240. data/dependencies/SDL/include/SDL_assert.h +0 -320
  241. data/dependencies/SDL/include/SDL_atomic.h +0 -415
  242. data/dependencies/SDL/include/SDL_audio.h +0 -1500
  243. data/dependencies/SDL/include/SDL_clipboard.h +0 -141
  244. data/dependencies/SDL/include/SDL_config.h +0 -331
  245. data/dependencies/SDL/include/SDL_cpuinfo.h +0 -594
  246. data/dependencies/SDL/include/SDL_endian.h +0 -348
  247. data/dependencies/SDL/include/SDL_error.h +0 -163
  248. data/dependencies/SDL/include/SDL_events.h +0 -1166
  249. data/dependencies/SDL/include/SDL_filesystem.h +0 -149
  250. data/dependencies/SDL/include/SDL_gamecontroller.h +0 -1074
  251. data/dependencies/SDL/include/SDL_gesture.h +0 -117
  252. data/dependencies/SDL/include/SDL_guid.h +0 -100
  253. data/dependencies/SDL/include/SDL_haptic.h +0 -1341
  254. data/dependencies/SDL/include/SDL_hidapi.h +0 -451
  255. data/dependencies/SDL/include/SDL_hints.h +0 -2569
  256. data/dependencies/SDL/include/SDL_joystick.h +0 -1066
  257. data/dependencies/SDL/include/SDL_keyboard.h +0 -353
  258. data/dependencies/SDL/include/SDL_keycode.h +0 -358
  259. data/dependencies/SDL/include/SDL_loadso.h +0 -115
  260. data/dependencies/SDL/include/SDL_log.h +0 -404
  261. data/dependencies/SDL/include/SDL_main.h +0 -275
  262. data/dependencies/SDL/include/SDL_mouse.h +0 -465
  263. data/dependencies/SDL/include/SDL_mutex.h +0 -471
  264. data/dependencies/SDL/include/SDL_name.h +0 -33
  265. data/dependencies/SDL/include/SDL_pixels.h +0 -644
  266. data/dependencies/SDL/include/SDL_platform.h +0 -261
  267. data/dependencies/SDL/include/SDL_quit.h +0 -58
  268. data/dependencies/SDL/include/SDL_rect.h +0 -376
  269. data/dependencies/SDL/include/SDL_render.h +0 -1919
  270. data/dependencies/SDL/include/SDL_revision.h +0 -7
  271. data/dependencies/SDL/include/SDL_rwops.h +0 -841
  272. data/dependencies/SDL/include/SDL_sensor.h +0 -322
  273. data/dependencies/SDL/include/SDL_shape.h +0 -155
  274. data/dependencies/SDL/include/SDL_stdinc.h +0 -830
  275. data/dependencies/SDL/include/SDL_surface.h +0 -997
  276. data/dependencies/SDL/include/SDL_system.h +0 -623
  277. data/dependencies/SDL/include/SDL_syswm.h +0 -386
  278. data/dependencies/SDL/include/SDL_test_images.h +0 -78
  279. data/dependencies/SDL/include/SDL_test_random.h +0 -115
  280. data/dependencies/SDL/include/SDL_thread.h +0 -464
  281. data/dependencies/SDL/include/SDL_timer.h +0 -222
  282. data/dependencies/SDL/include/SDL_touch.h +0 -150
  283. data/dependencies/SDL/include/SDL_version.h +0 -204
  284. data/dependencies/SDL/include/SDL_video.h +0 -2150
  285. data/dependencies/SDL/include/SDL_vulkan.h +0 -215
  286. data/dependencies/SDL/include/begin_code.h +0 -187
  287. data/dependencies/SDL/lib/x64/libSDL2.dll.a +0 -0
  288. data/dependencies/SDL/lib/x86/libSDL2.dll.a +0 -0
  289. data/dependencies/SDL_sound/SDL_sound.h +0 -725
  290. data/ext/gosu/extconf.rb +0 -119
  291. data/include/Gosu/IO.hpp +0 -254
  292. data/include/Gosu/ImageData.hpp +0 -53
  293. data/include/Gosu/Inspection.hpp +0 -7
  294. data/lib/SDL2.dll +0 -0
  295. data/lib/gosu/patches.rb +0 -66
  296. data/lib/gosu/run.rb +0 -20
  297. data/lib/gosu/swig_patches.rb +0 -110
  298. data/lib64/SDL2.dll +0 -0
  299. data/src/BlockAllocator.cpp +0 -131
  300. data/src/BlockAllocator.hpp +0 -32
  301. data/src/DirectoriesApple.cpp +0 -69
  302. data/src/DirectoriesUnix.cpp +0 -46
  303. data/src/DirectoriesWin.cpp +0 -65
  304. data/src/EmptyImageData.hpp +0 -52
  305. data/src/FileUnix.cpp +0 -99
  306. data/src/FileWin.cpp +0 -88
  307. data/src/IO.cpp +0 -60
  308. data/src/Iconv.hpp +0 -51
  309. data/src/Inspection.cpp +0 -27
  310. data/src/LargeImageData.cpp +0 -215
  311. data/src/LargeImageData.hpp +0 -39
  312. data/src/Log.hpp +0 -19
  313. data/src/RubyGosu.cxx +0 -13100
  314. data/src/RubyGosu.h +0 -49
  315. data/src/WinUtility.cpp +0 -61
  316. data/src/WinUtility.hpp +0 -27
  317. /data/dependencies/SDL/include/{SDL_opengles2_gl2.h → SDL3/SDL_opengles2_gl2.h} +0 -0
  318. /data/dependencies/SDL/include/{SDL_opengles2_gl2ext.h → SDL3/SDL_opengles2_gl2ext.h} +0 -0
  319. /data/dependencies/SDL/include/{SDL_opengles2_gl2platform.h → SDL3/SDL_opengles2_gl2platform.h} +0 -0
  320. /data/dependencies/SDL/include/{SDL_opengles2_khrplatform.h → SDL3/SDL_opengles2_khrplatform.h} +0 -0
@@ -36,16 +36,16 @@
36
36
  *
37
37
  * The features of utf8proc include:
38
38
  *
39
- * - Transformation of strings (@ref utf8proc_map) to:
39
+ * - Transformation of strings (utf8proc_map()) to:
40
40
  * - decompose (@ref UTF8PROC_DECOMPOSE) or compose (@ref UTF8PROC_COMPOSE) Unicode combining characters (http://en.wikipedia.org/wiki/Combining_character)
41
41
  * - canonicalize Unicode compatibility characters (@ref UTF8PROC_COMPAT)
42
42
  * - strip "ignorable" (@ref UTF8PROC_IGNORE) characters, control characters (@ref UTF8PROC_STRIPCC), or combining characters such as accents (@ref UTF8PROC_STRIPMARK)
43
43
  * - case-folding (@ref UTF8PROC_CASEFOLD)
44
- * - Unicode normalization: @ref utf8proc_NFD, @ref utf8proc_NFC, @ref utf8proc_NFKD, @ref utf8proc_NFKC
45
- * - Detecting grapheme boundaries (@ref utf8proc_grapheme_break and @ref UTF8PROC_CHARBOUND)
46
- * - Character-width computation: @ref utf8proc_charwidth
47
- * - Classification of characters by Unicode category: @ref utf8proc_category and @ref utf8proc_category_string
48
- * - Encode (@ref utf8proc_encode_char) and decode (@ref utf8proc_iterate) Unicode codepoints to/from UTF-8.
44
+ * - Unicode normalization: utf8proc_NFD(), utf8proc_NFC(), utf8proc_NFKD(), utf8proc_NFKC()
45
+ * - Detecting grapheme boundaries (utf8proc_grapheme_break() and @ref UTF8PROC_CHARBOUND)
46
+ * - Character-width computation: utf8proc_charwidth()
47
+ * - Classification of characters by Unicode category: utf8proc_category() and utf8proc_category_string()
48
+ * - Encode (utf8proc_encode_char()) and decode (utf8proc_iterate()) Unicode codepoints to/from UTF-8.
49
49
  */
50
50
 
51
51
  /** @file */
@@ -59,7 +59,7 @@
59
59
  * semantic-versioning rules (http://semver.org) based on API
60
60
  * compatibility.
61
61
  *
62
- * This is also returned at runtime by @ref utf8proc_version; however, the
62
+ * This is also returned at runtime by utf8proc_version(); however, the
63
63
  * runtime version may append a string like "-dev" to the version number
64
64
  * for prerelease versions.
65
65
  *
@@ -71,7 +71,7 @@
71
71
  /** The MAJOR version number (increased when backwards API compatibility is broken). */
72
72
  #define UTF8PROC_VERSION_MAJOR 2
73
73
  /** The MINOR version number (increased when new functionality is added in a backwards-compatible manner). */
74
- #define UTF8PROC_VERSION_MINOR 8
74
+ #define UTF8PROC_VERSION_MINOR 12
75
75
  /** The PATCH version (increased for fixes that do not change the API). */
76
76
  #define UTF8PROC_VERSION_PATCH 0
77
77
  /** @} */
@@ -79,7 +79,7 @@
79
79
  #include <stdlib.h>
80
80
 
81
81
  #if defined(_MSC_VER) && _MSC_VER < 1800
82
- // MSVC prior to 2013 lacked stdbool.h and inttypes.h
82
+ // MSVC prior to 2013 lacked stdbool.h and stdint.h
83
83
  typedef signed char utf8proc_int8_t;
84
84
  typedef unsigned char utf8proc_uint8_t;
85
85
  typedef short utf8proc_int16_t;
@@ -107,7 +107,7 @@ typedef bool utf8proc_bool;
107
107
  #else
108
108
  # include <stddef.h>
109
109
  # include <stdbool.h>
110
- # include <inttypes.h>
110
+ # include <stdint.h>
111
111
  typedef int8_t utf8proc_int8_t;
112
112
  typedef uint8_t utf8proc_uint8_t;
113
113
  typedef int16_t utf8proc_int16_t;
@@ -121,7 +121,9 @@ typedef bool utf8proc_bool;
121
121
  #include <limits.h>
122
122
 
123
123
  #ifdef UTF8PROC_STATIC
124
- # define UTF8PROC_DLLEXPORT
124
+ # ifndef UTF8PROC_DLLEXPORT
125
+ # define UTF8PROC_DLLEXPORT
126
+ # endif
125
127
  #else
126
128
  # ifdef _WIN32
127
129
  # ifdef UTF8PROC_EXPORTS
@@ -141,7 +143,9 @@ extern "C" {
141
143
  #endif
142
144
 
143
145
  /**
144
- * Option flags used by several functions in the library.
146
+ * Option flags used by several functions in the library. For
147
+ * `unsigned int options` arguments, you can pass a bitwise-or of these
148
+ * enumerated constants.
145
149
  */
146
150
  typedef enum {
147
151
  /** The given UTF-8 input is NULL terminated. */
@@ -150,7 +154,7 @@ typedef enum {
150
154
  UTF8PROC_STABLE = (1<<1),
151
155
  /** Compatibility decomposition (i.e. formatting information is lost). */
152
156
  UTF8PROC_COMPAT = (1<<2),
153
- /** Return a result with decomposed characters. */
157
+ /** Return a result with composed characters. */
154
158
  UTF8PROC_COMPOSE = (1<<3),
155
159
  /** Return a result with decomposed characters. */
156
160
  UTF8PROC_DECOMPOSE = (1<<4),
@@ -208,7 +212,7 @@ typedef enum {
208
212
  /**
209
213
  * Strip unassigned codepoints.
210
214
  */
211
- UTF8PROC_STRIPNA = (1<<14),
215
+ UTF8PROC_STRIPNA = (1<<14)
212
216
  } utf8proc_option_t;
213
217
 
214
218
  /** @name Error codes
@@ -255,25 +259,64 @@ typedef struct utf8proc_property_struct {
255
259
  utf8proc_uint16_t uppercase_seqindex;
256
260
  utf8proc_uint16_t lowercase_seqindex;
257
261
  utf8proc_uint16_t titlecase_seqindex;
258
- utf8proc_uint16_t comb_index;
262
+ /**
263
+ * Character combining table.
264
+ *
265
+ * The character combining table is formally indexed by two
266
+ * characters, the first and second character that might form a
267
+ * combining pair. The table entry then contains the combined
268
+ * character. Most character pairs cannot be combined. There are
269
+ * about 1,000 characters that can be the first character in a
270
+ * combining pair, and for most, there are only a handful for
271
+ * possible second characters.
272
+ *
273
+ * The combining table is stored as sparse matrix in the CSR
274
+ * (compressed sparse row) format. That is, it is stored as two
275
+ * arrays, `utf8proc_uint32_t utf8proc_combinations_second[]` and
276
+ * `utf8proc_uint32_t utf8proc_combinations_combined[]`. These
277
+ * contain the second combining characters and the combined
278
+ * character of every combining pair.
279
+ *
280
+ * - `comb_index`: Index into the combining table if this character
281
+ * is the first character in a combining pair, else 0x3ff
282
+ *
283
+ * - `comb_length`: Number of table entries for this first character
284
+ *
285
+ * - `comb_is_second`: As optimization we also record whether this
286
+ * character is the second combining character in any pair. If
287
+ * not, we can skip the table lookup.
288
+ *
289
+ * A table lookup starts from a given character pair. It first
290
+ * checks whether the first character is stored in the table
291
+ * (checking whether the index is 0x3ff) and whether the second
292
+ * index is stored in the table (looking at `comb_is_second`). If
293
+ * so, the `comb_length` table entries will be checked sequentially
294
+ * for a match.
295
+ */
296
+ utf8proc_uint16_t comb_index:10;
297
+ utf8proc_uint16_t comb_length:5;
298
+ utf8proc_uint16_t comb_issecond:1;
259
299
  unsigned bidi_mirrored:1;
260
300
  unsigned comp_exclusion:1;
261
301
  /**
262
302
  * Can this codepoint be ignored?
263
303
  *
264
- * Used by @ref utf8proc_decompose_char when @ref UTF8PROC_IGNORE is
304
+ * Used by utf8proc_decompose_char() when @ref UTF8PROC_IGNORE is
265
305
  * passed as an option.
266
306
  */
267
307
  unsigned ignorable:1;
268
308
  unsigned control_boundary:1;
269
309
  /** The width of the codepoint. */
270
310
  unsigned charwidth:2;
271
- unsigned pad:2;
311
+ /** East Asian width class A */
312
+ unsigned ambiguous_width:1;
313
+ unsigned pad:1;
272
314
  /**
273
315
  * Boundclass.
274
316
  * @see utf8proc_boundclass_t.
275
317
  */
276
- unsigned boundclass:8;
318
+ unsigned boundclass:6;
319
+ unsigned indic_conjunct_break:2;
277
320
  } utf8proc_property_t;
278
321
 
279
322
  /** Unicode categories. */
@@ -307,7 +350,7 @@ typedef enum {
307
350
  UTF8PROC_CATEGORY_CC = 26, /**< Other, control */
308
351
  UTF8PROC_CATEGORY_CF = 27, /**< Other, format */
309
352
  UTF8PROC_CATEGORY_CS = 28, /**< Other, surrogate */
310
- UTF8PROC_CATEGORY_CO = 29, /**< Other, private use */
353
+ UTF8PROC_CATEGORY_CO = 29 /**< Other, private use */
311
354
  } utf8proc_category_t;
312
355
 
313
356
  /** Bidirectional character classes. */
@@ -334,7 +377,7 @@ typedef enum {
334
377
  UTF8PROC_BIDI_CLASS_LRI = 20, /**< Left-to-Right Isolate */
335
378
  UTF8PROC_BIDI_CLASS_RLI = 21, /**< Right-to-Left Isolate */
336
379
  UTF8PROC_BIDI_CLASS_FSI = 22, /**< First Strong Isolate */
337
- UTF8PROC_BIDI_CLASS_PDI = 23, /**< Pop Directional Isolate */
380
+ UTF8PROC_BIDI_CLASS_PDI = 23 /**< Pop Directional Isolate */
338
381
  } utf8proc_bidi_class_t;
339
382
 
340
383
  /** Decomposition type. */
@@ -354,7 +397,7 @@ typedef enum {
354
397
  UTF8PROC_DECOMP_TYPE_SMALL = 13, /**< Small */
355
398
  UTF8PROC_DECOMP_TYPE_SQUARE = 14, /**< Square */
356
399
  UTF8PROC_DECOMP_TYPE_FRACTION = 15, /**< Fraction */
357
- UTF8PROC_DECOMP_TYPE_COMPAT = 16, /**< Compat */
400
+ UTF8PROC_DECOMP_TYPE_COMPAT = 16 /**< Compat */
358
401
  } utf8proc_decomp_type_t;
359
402
 
360
403
  /** Boundclass property. (TR29) */
@@ -385,12 +428,20 @@ typedef enum {
385
428
  /* the Extended_Pictographic property is used in the Unicode 11
386
429
  grapheme-boundary rules, so we store it in the boundclass field */
387
430
  UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC = 19,
388
- UTF8PROC_BOUNDCLASS_E_ZWG = 20, /* UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC + ZWJ */
431
+ UTF8PROC_BOUNDCLASS_E_ZWG = 20 /* UTF8PROC_BOUNDCLASS_EXTENDED_PICTOGRAPHIC + ZWJ */
389
432
  } utf8proc_boundclass_t;
390
433
 
434
+ /** Indic_Conjunct_Break property. (TR44) */
435
+ typedef enum {
436
+ UTF8PROC_INDIC_CONJUNCT_BREAK_NONE = 0,
437
+ UTF8PROC_INDIC_CONJUNCT_BREAK_LINKER = 1,
438
+ UTF8PROC_INDIC_CONJUNCT_BREAK_CONSONANT = 2,
439
+ UTF8PROC_INDIC_CONJUNCT_BREAK_EXTEND = 3
440
+ } utf8proc_indic_conjunct_break_t;
441
+
391
442
  /**
392
- * Function pointer type passed to @ref utf8proc_map_custom and
393
- * @ref utf8proc_decompose_custom, which is used to specify a user-defined
443
+ * Function pointer type passed to utf8proc_map_custom() and
444
+ * utf8proc_decompose_custom(), which is used to specify a user-defined
394
445
  * mapping of codepoints to be applied in conjunction with other mappings.
395
446
  */
396
447
  typedef utf8proc_int32_t (*utf8proc_custom_func)(utf8proc_int32_t codepoint, void *data);
@@ -415,7 +466,7 @@ UTF8PROC_DLLEXPORT const char *utf8proc_unicode_version(void);
415
466
 
416
467
  /**
417
468
  * Returns an informative error string for the given utf8proc error code
418
- * (e.g. the error codes returned by @ref utf8proc_map).
469
+ * (e.g. the error codes returned by utf8proc_map()).
419
470
  */
420
471
  UTF8PROC_DLLEXPORT const char *utf8proc_errmsg(utf8proc_ssize_t errcode);
421
472
 
@@ -470,7 +521,7 @@ UTF8PROC_DLLEXPORT const utf8proc_property_t *utf8proc_get_property(utf8proc_int
470
521
  * @param dst the destination buffer.
471
522
  * @param bufsize the size of the destination buffer.
472
523
  * @param options one or more of the following flags:
473
- * - @ref UTF8PROC_REJECTNA - return an error `codepoint` is unassigned
524
+ * - @ref UTF8PROC_REJECTNA - return an error if `codepoint` is unassigned
474
525
  * - @ref UTF8PROC_IGNORE - strip "default ignorable" codepoints
475
526
  * - @ref UTF8PROC_CASEFOLD - apply Unicode casefolding
476
527
  * - @ref UTF8PROC_COMPAT - replace certain codepoints with their
@@ -481,12 +532,18 @@ UTF8PROC_DLLEXPORT const utf8proc_property_t *utf8proc_get_property(utf8proc_int
481
532
  * - @ref UTF8PROC_STRIPNA - remove unassigned codepoints
482
533
  * @param last_boundclass
483
534
  * Pointer to an integer variable containing
484
- * the previous codepoint's boundary class if the @ref UTF8PROC_CHARBOUND
485
- * option is used. Otherwise, this parameter is ignored.
535
+ * the previous codepoint's (boundclass + (indic_conjunct_break << 8)) if the @ref UTF8PROC_CHARBOUND
536
+ * option is used. If the string is being processed in order, this can be initialized to 0 for
537
+ * the beginning of the string, and is thereafter updated automatically. Otherwise, this parameter is ignored.
538
+ *
539
+ * In the current version of utf8proc, the maximum destination buffer with the @ref UTF8PROC_DECOMPOSE
540
+ * option is 4 elements (or double that with @ref UTF8PROC_CHARBOUND), so this is a good default size.
541
+ * However, this may increase in future Unicode versions, so you should always check the return value
542
+ * as described below.
486
543
  *
487
544
  * @return
488
545
  * In case of success, the number of codepoints written is returned; in case
489
- * of an error, a negative error code is returned (@ref utf8proc_errmsg).
546
+ * of an error, a negative error code is returned (utf8proc_errmsg()).
490
547
  * @par
491
548
  * If the number of written codepoints would be bigger than `bufsize`, the
492
549
  * required buffer size is returned, while the buffer will be overwritten with
@@ -494,11 +551,11 @@ UTF8PROC_DLLEXPORT const utf8proc_property_t *utf8proc_get_property(utf8proc_int
494
551
  */
495
552
  UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(
496
553
  utf8proc_int32_t codepoint, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize,
497
- utf8proc_option_t options, int *last_boundclass
554
+ unsigned int options, utf8proc_int32_t *last_boundclass
498
555
  );
499
556
 
500
557
  /**
501
- * The same as @ref utf8proc_decompose_char, but acts on a whole UTF-8
558
+ * The same as utf8proc_decompose_char(), but acts on a whole UTF-8
502
559
  * string and orders the decomposed sequences correctly.
503
560
  *
504
561
  * If the @ref UTF8PROC_NULLTERM flag in `options` is set, processing
@@ -507,8 +564,8 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(
507
564
  * codepoints) is written into the buffer being pointed to by
508
565
  * `buffer` (which must contain at least `bufsize` entries). In case of
509
566
  * success, the number of codepoints written is returned; in case of an
510
- * error, a negative error code is returned (@ref utf8proc_errmsg).
511
- * See @ref utf8proc_decompose_custom to supply additional transformations.
567
+ * error, a negative error code is returned (utf8proc_errmsg()).
568
+ * See utf8proc_decompose_custom() to supply additional transformations.
512
569
  *
513
570
  * If the number of written codepoints would be bigger than `bufsize`, the
514
571
  * required buffer size is returned, while the buffer will be overwritten with
@@ -516,18 +573,18 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(
516
573
  */
517
574
  UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose(
518
575
  const utf8proc_uint8_t *str, utf8proc_ssize_t strlen,
519
- utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options
576
+ utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, unsigned int options
520
577
  );
521
578
 
522
579
  /**
523
- * The same as @ref utf8proc_decompose, but also takes a `custom_func` mapping function
580
+ * The same as utf8proc_decompose(), but also takes a `custom_func` mapping function
524
581
  * that is called on each codepoint in `str` before any other transformations
525
582
  * (along with a `custom_data` pointer that is passed through to `custom_func`).
526
- * The `custom_func` argument is ignored if it is `NULL`. See also @ref utf8proc_map_custom.
583
+ * The `custom_func` argument is ignored if it is `NULL`. See also utf8proc_map_custom().
527
584
  */
528
585
  UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_custom(
529
586
  const utf8proc_uint8_t *str, utf8proc_ssize_t strlen,
530
- utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, utf8proc_option_t options,
587
+ utf8proc_int32_t *buffer, utf8proc_ssize_t bufsize, unsigned int options,
531
588
  utf8proc_custom_func custom_func, void *custom_data
532
589
  );
533
590
 
@@ -549,12 +606,9 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_custom(
549
606
  *
550
607
  * @return
551
608
  * In case of success, the length (in codepoints) of the normalized UTF-32 string is
552
- * returned; otherwise, a negative error code is returned (@ref utf8proc_errmsg).
553
- *
554
- * @warning The entries of the array pointed to by `str` have to be in the
555
- * range `0x0000` to `0x10FFFF`. Otherwise, the program might crash!
609
+ * returned; otherwise, a negative error code is returned (utf8proc_errmsg()).
556
610
  */
557
- UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *buffer, utf8proc_ssize_t length, utf8proc_option_t options);
611
+ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *buffer, utf8proc_ssize_t length, unsigned int options);
558
612
 
559
613
  /**
560
614
  * Reencodes the sequence of `length` codepoints pointed to by `buffer`
@@ -577,14 +631,14 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_normalize_utf32(utf8proc_int32_t *b
577
631
  * @return
578
632
  * In case of success, the length (in bytes) of the resulting nul-terminated
579
633
  * UTF-8 string is returned; otherwise, a negative error code is returned
580
- * (@ref utf8proc_errmsg).
634
+ * (utf8proc_errmsg()).
581
635
  *
582
636
  * @warning The amount of free space pointed to by `buffer` must
583
637
  * exceed the amount of the input data by one byte, and the
584
638
  * entries of the array pointed to by `str` have to be in the
585
639
  * range `0x0000` to `0x10FFFF`. Otherwise, the program might crash!
586
640
  */
587
- UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode(utf8proc_int32_t *buffer, utf8proc_ssize_t length, utf8proc_option_t options);
641
+ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_reencode(utf8proc_int32_t *buffer, utf8proc_ssize_t length, unsigned int options);
588
642
 
589
643
  /**
590
644
  * Given a pair of consecutive codepoints, return whether a grapheme break is
@@ -607,7 +661,7 @@ UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_grapheme_break_stateful(
607
661
  utf8proc_int32_t codepoint1, utf8proc_int32_t codepoint2, utf8proc_int32_t *state);
608
662
 
609
663
  /**
610
- * Same as @ref utf8proc_grapheme_break_stateful, except without support for the
664
+ * Same as utf8proc_grapheme_break_stateful(), except without support for the
611
665
  * Unicode 9 additions to the algorithm. Supported for legacy reasons.
612
666
  */
613
667
  UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_grapheme_break(
@@ -654,9 +708,17 @@ UTF8PROC_DLLEXPORT int utf8proc_isupper(utf8proc_int32_t c);
654
708
  *
655
709
  * @note
656
710
  * If you want to check for particular types of non-printable characters,
657
- * (analogous to `isprint` or `iscntrl`), use @ref utf8proc_category. */
711
+ * (analogous to `isprint` or `iscntrl`), use utf8proc_category(). */
658
712
  UTF8PROC_DLLEXPORT int utf8proc_charwidth(utf8proc_int32_t codepoint);
659
713
 
714
+ /**
715
+ * Given a codepoint, return whether it has East Asian width class A (Ambiguous)
716
+ *
717
+ * Codepoints with this property are considered to have charwidth 1 (if they are printable)
718
+ * but some East Asian fonts render them as double width.
719
+ */
720
+ UTF8PROC_DLLEXPORT utf8proc_bool utf8proc_charwidth_ambiguous(utf8proc_int32_t codepoint);
721
+
660
722
  /**
661
723
  * Return the Unicode category for the codepoint (one of the
662
724
  * @ref utf8proc_category_t constants.)
@@ -680,16 +742,22 @@ UTF8PROC_DLLEXPORT const char *utf8proc_category_string(utf8proc_int32_t codepoi
680
742
  * contain NULL characters with the string if `str` contained NULL
681
743
  * characters). Other flags in the `options` field are passed to the
682
744
  * functions defined above, and regarded as described. See also
683
- * @ref utf8proc_map_custom to supply a custom codepoint transformation.
745
+ * utf8proc_map_custom() to supply a custom codepoint transformation.
684
746
  *
685
747
  * In case of success the length of the new string is returned,
686
748
  * otherwise a negative error code is returned.
687
749
  *
688
750
  * @note The memory of the new UTF-8 string will have been allocated
689
751
  * with `malloc`, and should therefore be deallocated with `free`.
752
+ * However, it is safer to deallocate it with @ref utf8proc_free in
753
+ * case your application is linked to a different C library than utf8proc.
754
+ *
755
+ * @note `utf8proc_map` simply calls `utf8proc_decompose` followed by `utf8proc_reencode`,
756
+ * and applications requiring greater control over memory allocation should instead call
757
+ * those two functions directly.
690
758
  */
691
759
  UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map(
692
- const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options
760
+ const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, unsigned int options
693
761
  );
694
762
 
695
763
  /**
@@ -699,7 +767,7 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map(
699
767
  * The `custom_func` argument is ignored if it is `NULL`.
700
768
  */
701
769
  UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map_custom(
702
- const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, utf8proc_option_t options,
770
+ const utf8proc_uint8_t *str, utf8proc_ssize_t strlen, utf8proc_uint8_t **dstptr, unsigned int options,
703
771
  utf8proc_custom_func custom_func, void *custom_data
704
772
  );
705
773
 
@@ -707,8 +775,13 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map_custom(
707
775
  *
708
776
  * Returns a pointer to newly allocated memory of a NFD, NFC, NFKD, NFKC or
709
777
  * NFKC_Casefold normalized version of the null-terminated string `str`. These
710
- * are shortcuts to calling @ref utf8proc_map with @ref UTF8PROC_NULLTERM
778
+ * are shortcuts to calling utf8proc_map() with @ref UTF8PROC_NULLTERM
711
779
  * combined with @ref UTF8PROC_STABLE and flags indicating the normalization.
780
+ *
781
+ * @note The memory of the new UTF-8 string will have been allocated
782
+ * with `malloc`, and should therefore be deallocated with `free`.
783
+ * However, it is safer to deallocate it with @ref utf8proc_free in
784
+ * case your application is linked to a different C library than utf8proc.
712
785
  */
713
786
  /** @{ */
714
787
  /** NFD normalization (@ref UTF8PROC_DECOMPOSE). */
@@ -726,6 +799,14 @@ UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFKC(const utf8proc_uint8_t *str);
726
799
  UTF8PROC_DLLEXPORT utf8proc_uint8_t *utf8proc_NFKC_Casefold(const utf8proc_uint8_t *str);
727
800
  /** @} */
728
801
 
802
+ /**
803
+ * Deallocate memory allocated and returned by @ref utf8proc_map and similar functions
804
+ * (which simply calls the `free` function from the underlying C library linked to utf8proc).
805
+ * It is safer to call `utf8proc_free` than calling `free` directly, in case your application
806
+ * is linked to a different C library with incompatible `malloc` and `free` functions.
807
+ */
808
+ UTF8PROC_DLLEXPORT void utf8proc_free(utf8proc_uint8_t *ptr);
809
+
729
810
  #ifdef __cplusplus
730
811
  }
731
812
  #endif