add v 0.0.1
This commit is contained in:
parent
21519f3b9b
commit
e2fc37e969
7 changed files with 74 additions and 29 deletions
27
dune-project
Normal file
27
dune-project
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
(lang dune 3.9)
|
||||||
|
|
||||||
|
(name stringCodepointSplitter)
|
||||||
|
(version 0.0.1)
|
||||||
|
(generate_opam_files true)
|
||||||
|
|
||||||
|
(source
|
||||||
|
(github yoxem/stringCodepointSplitter))
|
||||||
|
|
||||||
|
(authors "Tan Kian-ting <yoxem@kianting.info>")
|
||||||
|
|
||||||
|
(maintainers "Tan Kian-ting <yoxem@kianting.info>")
|
||||||
|
(bug_reports https://github.com/Yoxem/stringCodepointSplitter/issues)
|
||||||
|
(license MIT)
|
||||||
|
|
||||||
|
(documentation https://github.com/Yoxem/stringCodepointSplitter/tree/main/docs)
|
||||||
|
|
||||||
|
(package
|
||||||
|
(name stringCodepointSplitter)
|
||||||
|
(synopsis "Split a string to a list of strings of a character by the unicode codepoint")
|
||||||
|
(description "Split a string to a list of strings of a character by the unicode codepoint.
|
||||||
|
|
||||||
|
It requires module Uutf.")
|
||||||
|
(depends ocaml>=4.14 dune uutf)
|
||||||
|
(tags (string utf8)))
|
||||||
|
|
||||||
|
; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project
|
4
lib/dune
Normal file
4
lib/dune
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
(library
|
||||||
|
(name stringCodepointSplitter)
|
||||||
|
(public_name stringCodepointSplitter)
|
||||||
|
(libraries uutf findlib.dynload))
|
|
@ -1,13 +1,13 @@
|
||||||
(*#use "topfind";;*)
|
|
||||||
open Stdlib
|
open Stdlib
|
||||||
open Uutf
|
|
||||||
|
|
||||||
(**
|
(**
|
||||||
The Module needs [Uutf] Module.
|
The Module needs [Uutf] Module.
|
||||||
|
|
||||||
It only contains [split_string_by_unicode_codepoint], which splits an OCaml string [str] to a [string list]
|
It only contains [split_string_by_unicode_codepoint], which splits an OCaml string [str] to a [string list]
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
let _ = Findlib.init ();;
|
||||||
|
Fl_dynload.load_packages ["uutf"];;
|
||||||
|
|
||||||
|
|
||||||
(** Split an OCaml string [str] to a [string list]
|
(** Split an OCaml string [str] to a [string list]
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ let split_string_by_unicode_codepoint str =
|
||||||
(*Split a Ocaml string [str] to a `str list` *)
|
(*Split a Ocaml string [str] to a `str list` *)
|
||||||
let pred_codepoint = ref (-1) in
|
let pred_codepoint = ref (-1) in
|
||||||
let segmented_unit_list = ref [] in
|
let segmented_unit_list = ref [] in
|
||||||
let iterator x y z =
|
let iterator x y _ =
|
||||||
let _ = if !pred_codepoint > -1 then
|
let _ = if !pred_codepoint > -1 then
|
||||||
let current_codepoint = y in
|
let current_codepoint = y in
|
||||||
let pred_char_len = current_codepoint - !pred_codepoint in
|
let pred_char_len = current_codepoint - !pred_codepoint in
|
||||||
|
@ -48,7 +48,3 @@ let split_string_by_unicode_codepoint str =
|
||||||
else
|
else
|
||||||
!segmented_unit_list;;
|
!segmented_unit_list;;
|
||||||
|
|
||||||
|
|
||||||
List.map (fun x -> print_string (x ^ ", ")) (split_string_by_unicode_codepoint "m̄知 who you're.");;
|
|
||||||
|
|
||||||
|
|
37
stringCodepointSplitter.opam
Normal file
37
stringCodepointSplitter.opam
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# This file is generated by dune, edit dune-project instead
|
||||||
|
opam-version: "2.0"
|
||||||
|
version: "0.0.1"
|
||||||
|
synopsis:
|
||||||
|
"Split a string to a list of strings of a character by the unicode codepoint"
|
||||||
|
description: """
|
||||||
|
Split a string to a list of strings of a character by the unicode codepoint.
|
||||||
|
|
||||||
|
It requires module Uutf."""
|
||||||
|
maintainer: ["Tan Kian-ting <yoxem@kianting.info>"]
|
||||||
|
authors: ["Tan Kian-ting <yoxem@kianting.info>"]
|
||||||
|
license: "MIT"
|
||||||
|
tags: ["string" "utf8"]
|
||||||
|
homepage: "https://github.com/yoxem/stringCodepointSplitter"
|
||||||
|
doc: "https://github.com/Yoxem/stringCodepointSplitter/tree/main/docs"
|
||||||
|
bug-reports: "https://github.com/Yoxem/stringCodepointSplitter/issues"
|
||||||
|
depends: [
|
||||||
|
"ocaml>=4.14"
|
||||||
|
"dune" {>= "3.9"}
|
||||||
|
"uutf"
|
||||||
|
"odoc" {with-doc}
|
||||||
|
]
|
||||||
|
build: [
|
||||||
|
["dune" "subst"] {dev}
|
||||||
|
[
|
||||||
|
"dune"
|
||||||
|
"build"
|
||||||
|
"-p"
|
||||||
|
name
|
||||||
|
"-j"
|
||||||
|
jobs
|
||||||
|
"@install"
|
||||||
|
"@runtest" {with-test}
|
||||||
|
"@doc" {with-doc}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
dev-repo: "git+https://github.com/yoxem/stringCodepointSplitter.git"
|
|
@ -1,21 +0,0 @@
|
||||||
opam-version: "2.0"
|
|
||||||
name: "stringCodepointSplitter"
|
|
||||||
version: "0.1"
|
|
||||||
synopsis: "Split a string to a list of strings of a character by the unicode codepoint"
|
|
||||||
description: """
|
|
||||||
Split a string to a list of strings of a character by the unicode codepoint.
|
|
||||||
|
|
||||||
It requires module Uutf.
|
|
||||||
"""
|
|
||||||
maintainer: "Tan Kian-ting <yoxem@kianting.info>"
|
|
||||||
authors: "Tan Kian-ting <yoxem@kianting.info>"
|
|
||||||
license: "MIT License"
|
|
||||||
homepage: "https://github.com/Yoxem/stringCodepointSplitter"
|
|
||||||
bug-reports: "https://github.com/Yoxem/stringCodepointSplitter/issues"
|
|
||||||
dev-repo: "https://github.com/Yoxem/stringCodepointSplitter"
|
|
||||||
depends: [ "ocaml" "uutf" ]
|
|
||||||
build: [
|
|
||||||
["./configure" "--prefix=%{prefix}%"]
|
|
||||||
[make]
|
|
||||||
]
|
|
||||||
install: [make "install"]
|
|
2
test/dune
Normal file
2
test/dune
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
(test
|
||||||
|
(name stringCodepointSplitter))
|
0
test/stringCodepointSplitter.ml
Normal file
0
test/stringCodepointSplitter.ml
Normal file
Loading…
Reference in a new issue