mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 15:55:14 +00:00
craft-csv: a SYLK diacritic on a space is the spacing accent
ISO 6937 writes a spacing accent as its diacritic followed by SPACE. ESC N B SPACE was read as a space and a combining acute; it is now the acute accent itself, and likewise for the other nine marks glibc's ISO_6937 map gives a spacing form.
This commit is contained in:
1 parent
e096b5eb9b
commit
503caef9c4
2 files changed
+18
-11
No files matched your search
+12
-10
@@ -241,20 +241,22 @@ fn parse_value(arg: &str) -> Value {
|
||||
|
||||
/// ISO 6937's diacritics (codes 0xC1–0xCF): each code, its combining mark, and the letters it
|
||||
/// composes with, as pairs of letter and precomposed letter (from Unicode's canonical composition).
|
||||
/// A diacritic on a SPACE is the spacing accent (`´`, `¨`, `ˇ`, ...), as in glibc's ISO_6937 map; the
|
||||
/// grave, circumflex and tilde have none, since `` ` ``, `^` and `~` are plain ASCII.
|
||||
const ISO6937_DIACRITICS: [(u8, char, &str); 13] = [
|
||||
(0xC1, '\u{0300}', "AÀaàEÈeèIÌiìNǸnǹOÒoòUÙuùWẀwẁYỲyỳ"), // grave
|
||||
(0xC2, '\u{0301}', "AÁaáCĆcćEÉeéGǴgǵIÍiíKḰkḱLĹlĺMḾmḿNŃnńOÓoóPṔpṕRŔrŕSŚsśUÚuúWẂwẃYÝyýZŹzź"), // acute
|
||||
(0xC2, '\u{0301}', " ´AÁaáCĆcćEÉeéGǴgǵIÍiíKḰkḱLĹlĺMḾmḿNŃnńOÓoóPṔpṕRŔrŕSŚsśUÚuúWẂwẃYÝyýZŹzź"), // acute
|
||||
(0xC3, '\u{0302}', "AÂaâCĈcĉEÊeêGĜgĝHĤhĥIÎiîJĴjĵOÔoôSŜsŝUÛuûWŴwŵYŶyŷZẐzẑ"), // circumflex
|
||||
(0xC4, '\u{0303}', "AÃaãEẼeẽIĨiĩNÑnñOÕoõUŨuũVṼvṽYỸyỹ"), // tilde
|
||||
(0xC5, '\u{0304}', "AĀaāEĒeēGḠgḡIĪiīOŌoōUŪuūYȲyȳ"), // macron
|
||||
(0xC6, '\u{0306}', "AĂaăEĔeĕGĞgğIĬiĭOŎoŏUŬuŭ"), // breve
|
||||
(0xC7, '\u{0307}', "AȦaȧBḂbḃCĊcċDḊdḋEĖeėFḞfḟGĠgġHḢhḣIİMṀmṁNṄnṅOȮoȯPṖpṗRṘrṙSṠsṡTṪtṫWẆwẇXẊxẋYẎyẏZŻzż"), // dot above
|
||||
(0xC8, '\u{0308}', "AÄaäEËeëHḦhḧIÏiïOÖoötẗUÜuüWẄwẅXẌxẍYŸyÿ"), // diaeresis
|
||||
(0xCA, '\u{030a}', "AÅaåUŮuůwẘyẙ"), // ring
|
||||
(0xCB, '\u{0327}', "CÇcçDḐdḑEȨeȩGĢgģHḨhḩKĶkķLĻlļNŅnņRŖrŗSŞsşTŢtţ"), // cedilla
|
||||
(0xCD, '\u{030b}', "OŐoőUŰuű"), // double acute
|
||||
(0xCE, '\u{0328}', "AĄaąEĘeęIĮiįOǪoǫUŲuų"), // ogonek
|
||||
(0xCF, '\u{030c}', "AǍaǎCČcčDĎdďEĚeěGǦgǧHȞhȟIǏiǐjǰKǨkǩLĽlľNŇnňOǑoǒRŘrřSŠsšTŤtťUǓuǔZŽzž"), // caron
|
||||
(0xC5, '\u{0304}', " ¯AĀaāEĒeēGḠgḡIĪiīOŌoōUŪuūYȲyȳ"), // macron
|
||||
(0xC6, '\u{0306}', " ˘AĂaăEĔeĕGĞgğIĬiĭOŎoŏUŬuŭ"), // breve
|
||||
(0xC7, '\u{0307}', " ˙AȦaȧBḂbḃCĊcċDḊdḋEĖeėFḞfḟGĠgġHḢhḣIİMṀmṁNṄnṅOȮoȯPṖpṗRṘrṙSṠsṡTṪtṫWẆwẇXẊxẋYẎyẏZŻzż"), // dot above
|
||||
(0xC8, '\u{0308}', " ¨AÄaäEËeëHḦhḧIÏiïOÖoötẗUÜuüWẄwẅXẌxẍYŸyÿ"), // diaeresis
|
||||
(0xCA, '\u{030a}', " ˚AÅaåUŮuůwẘyẙ"), // ring
|
||||
(0xCB, '\u{0327}', " ¸CÇcçDḐdḑEȨeȩGĢgģHḨhḩKĶkķLĻlļNŅnņRŖrŗSŞsşTŢtţ"), // cedilla
|
||||
(0xCD, '\u{030b}', " ˝OŐoőUŰuű"), // double acute
|
||||
(0xCE, '\u{0328}', " ˛AĄaąEĘeęIĮiįOǪoǫUŲuų"), // ogonek
|
||||
(0xCF, '\u{030c}', " ˇAǍaǎCČcčDĎdďEĚeěGǦgǧHȞhȟIǏiǐjǰKǨkǩLĽlľNŇnňOǑoǒRŘrřSŠsšTŤtťUǓuǔZŽzž"), // caron
|
||||
];
|
||||
|
||||
/// ISO 6937's spacing characters above ASCII (codes 0xA1–0xFE that aren't diacritics).
|
||||
|
||||
@@ -123,7 +123,8 @@ fn decodes_excels_character_escapes_in_text() {
|
||||
let file = "ID;PWXL;N;E\r\nC;Y1;X1;K\"Gr\u{1b}NHo\u{1b}N{e f\u{1b}NHur K\u{1b}NHoln\"\r\nC;Y2;X1;K\"Plain ASCII 123\"\r\n\
|
||||
C;Y3;X1;K\"\u{1b}NBe \u{1b}NAa \u{1b}NCa \u{1b}NKc \u{1b}NOs \u{1b}NMo \u{1b}NJa \u{1b}NDn\"\r\n\
|
||||
C;Y4;X1;K\"\u{1b}NAa \u{1b}NAZ\"\r\nC;Y5;X1;K\"\u{1b}Nq \u{1b}NyStra\u{1b}N{e \u{1b}Na\u{1b}Ni\"\r\n\
|
||||
C;Y6;X1;K\"\u{1b}NHq \u{1b}N\u{1b}NHo end\u{1b}N\"\r\nC;Y7;X1;K\"\u{1b}N\u{7f} \u{1b}NL \u{1b}X\"\r\nC;Y8;X1;K\"\u{1b}NH\u{1b}NHo \u{1b}NB\tx\"\r\nE\r\n";
|
||||
C;Y6;X1;K\"\u{1b}NHq \u{1b}N\u{1b}NHo end\u{1b}N\"\r\nC;Y7;X1;K\"\u{1b}N\u{7f} \u{1b}NL \u{1b}X\"\r\nC;Y8;X1;K\"\u{1b}NH\u{1b}NHo \u{1b}NB\tx\"\r\n\
|
||||
C;Y9;X1;K\"\u{1b}NB |\u{1b}NE |\u{1b}NF |\u{1b}NG |\u{1b}NH |\u{1b}NJ |\u{1b}NK |\u{1b}NM |\u{1b}NN |\u{1b}NO |\u{1b}NA |\u{1b}NC \"\r\nE\r\n";
|
||||
let sh = read(file.as_bytes()).unwrap();
|
||||
let value = |a: &str| sh.cells.get(&at(a)).map(|c| c.value.clone()).unwrap_or_default();
|
||||
let text = |s: &str| Value::Text(s.into());
|
||||
@@ -142,4 +143,8 @@ fn decodes_excels_character_escapes_in_text() {
|
||||
// A diacritic followed by another escape (or a control character) is kept as written, and the
|
||||
// next escape still decodes.
|
||||
assert_eq!(value("A8"), text("\u{1b}NHö \u{1b}NB\tx"));
|
||||
// A diacritic on a SPACE is the spacing accent: acute, macron, breve, dot above, diaeresis, ring,
|
||||
// cedilla, double acute, ogonek, caron. The grave and circumflex have none (`` ` `` and `^` are
|
||||
// ASCII), so they stay a space with the combining mark.
|
||||
assert_eq!(value("A9"), text("´|¯|˘|˙|¨|˚|¸|˝|˛|ˇ| \u{300}| \u{302}"));
|
||||
}
|
||||
Reference in new issue
Block a user