I have been messing around with converting a large Devanagari Sanskrit text to Brahmi using a simple mapping function. There is also this table showing how most of the characters map. I found one that doesn't though, the ऽ
. Right now I'm just mapping it to अ, but please correct me if I'm wrong.
What I'm wondering about though is how to convert Sanskrit Devanagari text to Brahmi. Can I just strip the diacritics and call it a day? Or do I need to be more careful and look at (unicode) character combinations (like letter + diacritic) to map to a single (or perhaps multiple) Brahmi letter(s)? How do I convert Sanskrit Devanagari to Brahmi?
Right now I have this (the mapping is just what I wanted to show in case it's relevant):
var MAP = {
"ऽ": "\u{11005}",
"ॠ": "𑀌",
"\u0905": "\u{11005}",
"\u0906": "\u{11006}",
"\u0907": "\u{11007}",
"\u0908": "\u{11008}",
"\u0909": "\u{11009}",
"\u090A": "\u{1100A}",
"\u090B": "\u{1100B}",
"\u090C": "\u{1100D}",
"\u090F": "\u{1100F}",
"\u0910": "\u{11010}",
"\u0913": "\u{11011}",
"\u0914": "\u{11012}",
"\u0915": "\u{11013}",
"\u0916": "\u{11014}",
"\u0917": "\u{11015}",
"\u0918": "\u{11016}",
"\u0919": "\u{11017}",
"\u091A": "\u{11018}",
"\u091B": "\u{11019}",
"\u091C": "\u{1101A}",
"\u091D": "\u{1101B}",
"\u091E": "\u{1101C}",
"\u091F": "\u{1101D}",
"\u0920": "\u{1101E}",
"\u0921": "\u{1101F}",
"\u0922": "\u{11020}",
"\u0923": "\u{11021}",
"\u0924": "\u{11022}",
"\u0925": "\u{11023}",
"\u0926": "\u{11024}",
"\u0927": "\u{11025}",
"\u0928": "\u{11026}",
"\u092A": "\u{11027}",
"\u092B": "\u{11028}",
"\u092C": "\u{11029}",
"\u092D": "\u{1102A}",
"\u092E": "\u{1102B}",
"\u092F": "\u{1102C}",
"\u0930": "\u{1102D}",
"\u0932": "\u{1102E}",
"\u0933": "\u{11034}",
"\u0935": "\u{1102F}",
"\u0936": "\u{11030}",
"\u0937": "\u{11031}",
"\u0938": "\u{11032}",
"\u0939": "\u{11033}",
"\u093E": "\u{11038}",
"\u093F": "\u{1103A}",
"\u0940": "\u{1103B}",
"\u0941": "\u{1103C}",
"\u0942": "\u{1103D}",
"\u0943": "\u{1103E}",
"\u0944": "\u{1103F}",
"\u0962": "\u{11040}",
"\u0963": "\u{11041}",
"\u0947": "\u{11042}",
"\u0948": "\u{11043}",
"\u094B": "\u{11044}",
"\u094C": "\u{11045}",
"\u094D": "\u{11046}",
"\u0964": "\u{11047}",
"\u0965": "\u{11048}",
"\u0966": "\u{11066}",
"\u0967": "\u{11067}",
"\u0968": "\u{11068}",
"\u0969": "\u{11069}",
"\u096A": "\u{1106A}",
"\u096B": "\u{1106B}",
"\u096C": "\u{1106C}",
"\u096D": "\u{1106D}",
"\u096E": "\u{1106E}",
"\u096F": "\u{1106F}"
}
var combining = [
'\u0900',
'\u0901',
'\u0902',
'\u0903',
'\u093a',
'\u093b',
'\u093c',
'\u093e',
'\u093f',
'\u0940',
'\u0941',
'\u0942',
'\u0943',
'\u0944',
'\u0945',
'\u0946',
'\u0947',
'\u0948',
'\u0949',
'\u094a',
'\u094b',
'\u094c',
'\u094d',
'\u094e',
'\u094f',
'\u0955',
'\u0956',
'\u0957',
'\uA8E0',
'\uA8E1',
'\uA8E2',
'\uA8E3',
'\uA8E4',
'\uA8E5',
'\uA8E6',
'\uA8E7',
'\uA8E8',
'\uA8E9',
'\uA8Ea',
'\uA8Eb',
'\uA8Ec',
'\uA8Ed',
'\uA8Ee',
'\uA8Ef',
'\uA8f0',
'\uA8f1',
'\u1CD1',
'\u1CD4',
'\u1CDb',
'\u1CDe',
'\u1CDf',
'\u1Ce2',
'\u1Ce3',
'\u1Ce4',
'\u1Ce5',
'\u1Ce6',
'\u1Ce7',
'\u1Ce8',
'\u1CF7',
]
var chars = []
for (var char of text) {
char = char
.replace(/\s+/g, '')
.replace(/[\{\};\:\.,\"\'\(\)।॥\[\]]/g, '')
if (!char) continue // ignore whitespace
if (combining.includes(char)) continue // ignore diacritics?
chars.push(MAP[char]) // brahmi character
}
What could I be doing better?
Note, I am wondering less about the code/technical aspects, and more about the linguistic aspect of orthography to orthography.