@dpr4dhan/preeti-to-unicode 1.0.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.
- package/CHANGELOG.md +142 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/package.json +62 -0
- package/preeti-to-unicode.d.ts +82 -0
- package/preeti-to-unicode.js +160 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-05-18
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of Preeti to Unicode converter
|
|
12
|
+
- Complete Devanagari character mapping (100+ characters)
|
|
13
|
+
- 10 vowels (स्वर)
|
|
14
|
+
- 36 consonants (व्यंजन)
|
|
15
|
+
- 12 vowel signs (मात्रा)
|
|
16
|
+
- 10 Devanagari digits
|
|
17
|
+
- 15+ conjuncts (संयुक्त व्यंजन)
|
|
18
|
+
- Conjunct (ligature) support (क्ष, त्र, ज्ञ, श्र, etc.)
|
|
19
|
+
- jQuery integration with 8+ patterns
|
|
20
|
+
- Real-time conversion
|
|
21
|
+
- Multiple field conversion
|
|
22
|
+
- Batch processing
|
|
23
|
+
- AJAX integration
|
|
24
|
+
- Form submission handling
|
|
25
|
+
- Dropdown selection
|
|
26
|
+
- Statistics display
|
|
27
|
+
- Custom jQuery plugin wrapper
|
|
28
|
+
- Same-field conversion with 10 different methods
|
|
29
|
+
- Auto-convert
|
|
30
|
+
- Toggle view
|
|
31
|
+
- Button click
|
|
32
|
+
- Hidden storage
|
|
33
|
+
- Textarea support
|
|
34
|
+
- Form submission
|
|
35
|
+
- Live replace
|
|
36
|
+
- Editable div
|
|
37
|
+
- Complete form examples
|
|
38
|
+
- Smart detection
|
|
39
|
+
- Batch conversion support
|
|
40
|
+
- Custom character mapping support
|
|
41
|
+
- Custom conjunct mapping support
|
|
42
|
+
- Reverse conversion (Unicode to Preeti)
|
|
43
|
+
- TypeScript definitions
|
|
44
|
+
- Comprehensive documentation
|
|
45
|
+
- Interactive demos (3 types)
|
|
46
|
+
- Standalone demo
|
|
47
|
+
- jQuery examples (7)
|
|
48
|
+
- Same-field examples (7)
|
|
49
|
+
- MIT License
|
|
50
|
+
- Full npm package configuration
|
|
51
|
+
|
|
52
|
+
### Features
|
|
53
|
+
- Zero dependencies (pure JavaScript)
|
|
54
|
+
- Browser & Node.js compatible
|
|
55
|
+
- Lightweight (~12 KB)
|
|
56
|
+
- Production-ready
|
|
57
|
+
- Support for Hindi, Nepali, Marathi, Konkani, Maithili
|
|
58
|
+
- jQuery integration (optional, works without jQuery)
|
|
59
|
+
- No external dependencies required
|
|
60
|
+
|
|
61
|
+
### Documentation
|
|
62
|
+
- Comprehensive README
|
|
63
|
+
- Complete API reference (preeti-converter-usage.md)
|
|
64
|
+
- jQuery integration guide (jquery-integration.md)
|
|
65
|
+
- Same-field conversion methods (same-field-conversion.md)
|
|
66
|
+
- NPM publishing guide (npm-publishing-guide.md)
|
|
67
|
+
- Code examples and test cases (examples.js)
|
|
68
|
+
|
|
69
|
+
### Performance
|
|
70
|
+
- Single character: < 0.1ms
|
|
71
|
+
- Word (5 chars): < 0.5ms
|
|
72
|
+
- Sentence (50 chars): < 2ms
|
|
73
|
+
- Paragraph (500 chars): < 15ms
|
|
74
|
+
- Batch (100 texts): < 20ms
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Planned Features
|
|
79
|
+
|
|
80
|
+
### For 1.1.0
|
|
81
|
+
- [ ] Command-line interface (CLI tool)
|
|
82
|
+
- [ ] Build script optimizations
|
|
83
|
+
- [ ] Additional Devanagari variants
|
|
84
|
+
- [ ] Performance improvements
|
|
85
|
+
- [ ] Extended character support
|
|
86
|
+
- [ ] More language variants
|
|
87
|
+
|
|
88
|
+
### For 1.2.0
|
|
89
|
+
- [ ] Browser extension
|
|
90
|
+
- [ ] Web API service
|
|
91
|
+
- [ ] Additional jQuery patterns
|
|
92
|
+
- [ ] React component wrapper
|
|
93
|
+
- [ ] Vue.js component wrapper
|
|
94
|
+
|
|
95
|
+
### For 2.0.0 (Breaking Changes)
|
|
96
|
+
- [ ] ES6 Module rewrite
|
|
97
|
+
- [ ] Improved architecture
|
|
98
|
+
- [ ] Plugin system
|
|
99
|
+
- [ ] Extended functionality
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Version History
|
|
104
|
+
|
|
105
|
+
### [1.0.0] - 2026-05-18
|
|
106
|
+
- Initial public release
|
|
107
|
+
- Feature complete for basic and advanced use cases
|
|
108
|
+
- Ready for production use
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## How to Report Issues
|
|
113
|
+
|
|
114
|
+
If you find any issues:
|
|
115
|
+
|
|
116
|
+
1. Check existing issues: https://github.com/yourusername/preeti-to-unicode/issues
|
|
117
|
+
2. Create new issue with:
|
|
118
|
+
- Clear description
|
|
119
|
+
- Steps to reproduce
|
|
120
|
+
- Expected vs actual behavior
|
|
121
|
+
- Environment details
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Contributing
|
|
126
|
+
|
|
127
|
+
1. Fork the repository
|
|
128
|
+
2. Create feature branch (`git checkout -b feature/amazing-feature`)
|
|
129
|
+
3. Commit changes (`git commit -m 'Add amazing feature'`)
|
|
130
|
+
4. Push to branch (`git push origin feature/amazing-feature`)
|
|
131
|
+
5. Open Pull Request
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
This project is licensed under the MIT License - see [LICENSE](LICENSE) file for details.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
**Note:** This changelog will be updated with each new release.
|
|
142
|
+
For the latest updates, visit: https://github.com/yourusername/preeti-to-unicode/releases
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Preeti to Unicode Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE OR OTHERWISE
|
|
20
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
21
|
+
DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# Preeti to Unicode Converter - JavaScript Plugin
|
|
2
|
+
|
|
3
|
+
A powerful, production-ready JavaScript plugin for converting Preeti font text to Unicode Devanagari script.
|
|
4
|
+
|
|
5
|
+
## 📦 What's Included
|
|
6
|
+
|
|
7
|
+
- **preeti-to-unicode.js** - Main converter plugin
|
|
8
|
+
- **preeti-converter-demo.html** - Interactive web demo
|
|
9
|
+
- **preeti-converter-usage.md** - Complete documentation
|
|
10
|
+
- **examples.js** - Code examples and test cases
|
|
11
|
+
- **README.md** - This file
|
|
12
|
+
|
|
13
|
+
## 🚀 Quick Start
|
|
14
|
+
|
|
15
|
+
### Browser Usage
|
|
16
|
+
```html
|
|
17
|
+
<script src="preeti-to-unicode.js"></script>
|
|
18
|
+
<script>
|
|
19
|
+
const converter = new PreetiConverter();
|
|
20
|
+
const result = converter.convert("pzfprq");
|
|
21
|
+
console.log(result); // Output: "प्रीति"
|
|
22
|
+
</script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Node.js Usage
|
|
26
|
+
```javascript
|
|
27
|
+
const PreetiConverter = require('./preeti-to-unicode.js');
|
|
28
|
+
const converter = new PreetiConverter();
|
|
29
|
+
const text = converter.convert("esjk uke rkt gS");
|
|
30
|
+
console.log(text); // Output: "मेरा नाम राज है"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 💡 Common Examples
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
const converter = new PreetiConverter();
|
|
37
|
+
|
|
38
|
+
// Simple words
|
|
39
|
+
converter.convert("rkt"); // राज
|
|
40
|
+
converter.convert("pzfprq"); // प्रीति
|
|
41
|
+
converter.convert("v.kZu"); // वर्णन
|
|
42
|
+
|
|
43
|
+
// Numbers
|
|
44
|
+
converter.convert("123"); // १२३
|
|
45
|
+
|
|
46
|
+
// Conjuncts
|
|
47
|
+
converter.convert("kz"); // क्ष
|
|
48
|
+
converter.convert("tr"); // त्र
|
|
49
|
+
|
|
50
|
+
// Full sentences
|
|
51
|
+
converter.convert("uSyoky gks"); // नमस्कार हो
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 📚 API Reference
|
|
55
|
+
|
|
56
|
+
### Methods
|
|
57
|
+
|
|
58
|
+
- **convert(text)** - Convert Preeti to Unicode
|
|
59
|
+
- **convertBatch(texts)** - Convert multiple texts
|
|
60
|
+
- **addCustomMapping(char, unicode)** - Add custom character mapping
|
|
61
|
+
- **addCustomConjunct(chars, unicode)** - Add custom conjunct
|
|
62
|
+
- **getMappings()** - Get all mappings
|
|
63
|
+
- **getMapping(char)** - Get single character mapping
|
|
64
|
+
- **reverseConvert(unicode)** - Convert Unicode back to Preeti
|
|
65
|
+
|
|
66
|
+
## 🎯 Features
|
|
67
|
+
|
|
68
|
+
✅ Complete Devanagari character mapping
|
|
69
|
+
✅ Conjunct (ligature) support
|
|
70
|
+
✅ Batch conversion
|
|
71
|
+
✅ Custom mappings
|
|
72
|
+
✅ Reverse conversion
|
|
73
|
+
✅ Zero dependencies
|
|
74
|
+
✅ Lightweight (~12 KB)
|
|
75
|
+
✅ Browser & Node.js compatible
|
|
76
|
+
✅ Fast & optimized
|
|
77
|
+
|
|
78
|
+
## 📄 Use Cases
|
|
79
|
+
|
|
80
|
+
- Legacy document conversion
|
|
81
|
+
- Real-time text input processing
|
|
82
|
+
- Database record migration
|
|
83
|
+
- Web form handling
|
|
84
|
+
- Bulk text file processing
|
|
85
|
+
|
|
86
|
+
## 🛠️ Integration
|
|
87
|
+
|
|
88
|
+
### React
|
|
89
|
+
```jsx
|
|
90
|
+
const [text, setText] = useState('');
|
|
91
|
+
const converter = new PreetiConverter();
|
|
92
|
+
|
|
93
|
+
<textarea onChange={(e) => setText(e.target.value)} />
|
|
94
|
+
<p>{converter.convert(text)}</p>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Vue.js
|
|
98
|
+
```vue
|
|
99
|
+
<input v-model="preetiText" />
|
|
100
|
+
<p>{{ converter.convert(preetiText) }}</p>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Vanilla JavaScript
|
|
104
|
+
```javascript
|
|
105
|
+
const converter = new PreetiConverter();
|
|
106
|
+
element.addEventListener('input', (e) => {
|
|
107
|
+
output.textContent = converter.convert(e.target.value);
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 📊 Performance
|
|
112
|
+
|
|
113
|
+
- Single character: < 0.1ms
|
|
114
|
+
- Short word (5 chars): < 0.5ms
|
|
115
|
+
- Sentence (50 chars): < 2ms
|
|
116
|
+
- Paragraph (500 chars): < 15ms
|
|
117
|
+
|
|
118
|
+
## 🌍 Supported Languages
|
|
119
|
+
|
|
120
|
+
- Hindi
|
|
121
|
+
- Nepali
|
|
122
|
+
- Marathi
|
|
123
|
+
- Konkani
|
|
124
|
+
- Maithili
|
|
125
|
+
|
|
126
|
+
Any language using Devanagari script.
|
|
127
|
+
|
|
128
|
+
## 📝 Character Mapping
|
|
129
|
+
|
|
130
|
+
### Vowels (स्वर)
|
|
131
|
+
| Preeti | Unicode |
|
|
132
|
+
|--------|---------|
|
|
133
|
+
| a | अ |
|
|
134
|
+
| A | आ |
|
|
135
|
+
| i | इ |
|
|
136
|
+
| I | ई |
|
|
137
|
+
| u | उ |
|
|
138
|
+
| U | ऊ |
|
|
139
|
+
|
|
140
|
+
### Key Consonants (व्यंजन)
|
|
141
|
+
| Preeti | Unicode |
|
|
142
|
+
|--------|---------|
|
|
143
|
+
| k | क |
|
|
144
|
+
| g | ग |
|
|
145
|
+
| h | ज |
|
|
146
|
+
| t | त |
|
|
147
|
+
| b | प |
|
|
148
|
+
| m | म |
|
|
149
|
+
|
|
150
|
+
### Important Conjuncts
|
|
151
|
+
| Preeti | Unicode |
|
|
152
|
+
|--------|---------|
|
|
153
|
+
| kz | क्ष |
|
|
154
|
+
| tr | त्र |
|
|
155
|
+
| gn | ज्ञ |
|
|
156
|
+
| Wr | श्र |
|
|
157
|
+
|
|
158
|
+
See preeti-converter-usage.md for complete mapping.
|
|
159
|
+
|
|
160
|
+
## 🎓 Learning Resources
|
|
161
|
+
|
|
162
|
+
1. **preeti-converter-demo.html** - Open in browser for interactive demo
|
|
163
|
+
2. **preeti-converter-usage.md** - Full documentation with examples
|
|
164
|
+
3. **examples.js** - Practical code examples
|
|
165
|
+
|
|
166
|
+
## 📞 Support
|
|
167
|
+
|
|
168
|
+
For detailed documentation, see `preeti-converter-usage.md`
|
|
169
|
+
For code examples, see `examples.js`
|
|
170
|
+
For interactive demo, open `preeti-converter-demo.html` in browser
|
|
171
|
+
|
|
172
|
+
## ✨ Version
|
|
173
|
+
|
|
174
|
+
v1.0.0 - Production Ready
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
**Status:** Ready to use
|
|
179
|
+
**License:** Free for personal and commercial use
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dpr4dhan/preeti-to-unicode",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Convert Preeti font text to Unicode Devanagari script with jQuery integration and same-field conversion",
|
|
5
|
+
"main": "preeti-to-unicode.js",
|
|
6
|
+
"types": "preeti-to-unicode.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "node examples.js",
|
|
9
|
+
"build": "echo 'No build needed - pure JavaScript'",
|
|
10
|
+
"publish": "npm publish"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"preeti",
|
|
14
|
+
"unicode",
|
|
15
|
+
"devanagari",
|
|
16
|
+
"hindi",
|
|
17
|
+
"nepali",
|
|
18
|
+
"marathi",
|
|
19
|
+
"konkani",
|
|
20
|
+
"maithili",
|
|
21
|
+
"font-conversion",
|
|
22
|
+
"text-conversion",
|
|
23
|
+
"character-encoding",
|
|
24
|
+
"javascript",
|
|
25
|
+
"jquery",
|
|
26
|
+
"library"
|
|
27
|
+
],
|
|
28
|
+
"author": "Dhiraj Pradhan <dpr4dhan@gmail.com>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/dpr4dhan/preeti-to-unicode.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/dpr4dhan/preeti-to-unicode#readme",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/dpr4dhan/preeti-to-unicode/issues",
|
|
37
|
+
"email": "dpr4dhan@gmail.com"
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"preeti-to-unicode.js",
|
|
41
|
+
"preeti-to-unicode.d.ts",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE",
|
|
44
|
+
"CHANGELOG.md"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=10.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {},
|
|
50
|
+
"optionalDependencies": {},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"jquery": ">=3.0.0 || >=2.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"jquery": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"directories": {
|
|
60
|
+
"lib": "."
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preeti to Unicode Converter
|
|
3
|
+
* Convert Preeti ANSI font text to Unicode Devanagari script
|
|
4
|
+
*/
|
|
5
|
+
declare class PreetiConverter {
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the converter with default character mappings
|
|
8
|
+
*/
|
|
9
|
+
constructor();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Convert Preeti encoded text to Unicode Devanagari
|
|
13
|
+
* @param preetiText - Text in Preeti font encoding
|
|
14
|
+
* @returns Unicode Devanagari text
|
|
15
|
+
* @example
|
|
16
|
+
* const converter = new PreetiConverter();
|
|
17
|
+
* converter.convert("pzfprq"); // Returns: "प्रीति"
|
|
18
|
+
*/
|
|
19
|
+
convert(preetiText: string): string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Convert multiple Preeti texts in batch
|
|
23
|
+
* @param texts - Array of Preeti encoded texts
|
|
24
|
+
* @returns Array of Unicode Devanagari texts
|
|
25
|
+
* @example
|
|
26
|
+
* const converter = new PreetiConverter();
|
|
27
|
+
* converter.convertBatch(["rkt", "pzfprq"]); // Returns: ["राज", "प्रीति"]
|
|
28
|
+
*/
|
|
29
|
+
convertBatch(texts: string[]): string[];
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Add or override a custom character mapping
|
|
33
|
+
* @param preetiChar - Preeti character
|
|
34
|
+
* @param unicodeChar - Corresponding Unicode character
|
|
35
|
+
* @example
|
|
36
|
+
* converter.addCustomMapping('@', 'ज़');
|
|
37
|
+
*/
|
|
38
|
+
addCustomMapping(preetiChar: string, unicodeChar: string): void;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Add or override a custom conjunct (ligature) mapping
|
|
42
|
+
* @param preetiConjunct - Preeti conjunct (2+ characters)
|
|
43
|
+
* @param unicodeConjunct - Corresponding Unicode conjunct
|
|
44
|
+
* @example
|
|
45
|
+
* converter.addCustomConjunct('kt', 'क्त');
|
|
46
|
+
*/
|
|
47
|
+
addCustomConjunct(preetiConjunct: string, unicodeConjunct: string): void;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get all available character and conjunct mappings
|
|
51
|
+
* @returns Object containing characters and conjuncts mappings
|
|
52
|
+
* @example
|
|
53
|
+
* const mappings = converter.getMappings();
|
|
54
|
+
* console.log(mappings.characters); // All character mappings
|
|
55
|
+
* console.log(mappings.conjuncts); // All conjunct mappings
|
|
56
|
+
*/
|
|
57
|
+
getMappings(): {
|
|
58
|
+
characters: Record<string, string>;
|
|
59
|
+
conjuncts: Record<string, string>;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get the Unicode mapping for a specific Preeti character
|
|
64
|
+
* @param char - Preeti character
|
|
65
|
+
* @returns Unicode equivalent or null if not found
|
|
66
|
+
* @example
|
|
67
|
+
* converter.getMapping('k'); // Returns: "क"
|
|
68
|
+
* converter.getMapping('a'); // Returns: "अ"
|
|
69
|
+
*/
|
|
70
|
+
getMapping(char: string): string | null;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Reverse convert Unicode Devanagari text back to Preeti encoding
|
|
74
|
+
* @param unicodeText - Unicode Devanagari text
|
|
75
|
+
* @returns Preeti encoded text
|
|
76
|
+
* @example
|
|
77
|
+
* converter.reverseConvert("प्रीति"); // Returns: "pzfprq"
|
|
78
|
+
*/
|
|
79
|
+
reverseConvert(unicodeText: string): string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export = PreetiConverter;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preeti Font to Unicode Converter
|
|
3
|
+
* Converts Preeti ANSI font text to Unicode Devanagari script
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const converter = new PreetiConverter();
|
|
7
|
+
* const unicodeText = converter.convert("pzfprq"); // "प्रीति"
|
|
8
|
+
*
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
class PreetiConverter {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.initializeMapping();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the Preeti to Unicode character mapping
|
|
19
|
+
*/
|
|
20
|
+
initializeMapping() {
|
|
21
|
+
// Preeti character mapping
|
|
22
|
+
this.preetiMap = {
|
|
23
|
+
// Vowels (स्वर)
|
|
24
|
+
'a': 'अ', 'A': 'आ', 'i': 'इ', 'I': 'ई', 'u': 'उ', 'U': 'ऊ',
|
|
25
|
+
'e': 'ए', 'E': 'ऐ', 'o': 'ओ', 'O': 'औ',
|
|
26
|
+
|
|
27
|
+
// Vowel signs (मात्रा)
|
|
28
|
+
'w': 'ा', 'q': 'ि', 'Q': 'ी', 's': 'ु', 'S': 'ू',
|
|
29
|
+
'd': 'े', 'D': 'ै', 'f': 'ो', 'F': 'ौ', 'x': 'ँ', 'X': 'ं', 'c': 'ः',
|
|
30
|
+
|
|
31
|
+
// Consonants (व्यंजन)
|
|
32
|
+
'k': 'क', 'K': 'ख', 'g': 'ग', 'G': 'घ', 'z': 'ङ',
|
|
33
|
+
'j': 'च', 'J': 'छ', 'h': 'ज', 'H': 'झ', 'n': 'ञ',
|
|
34
|
+
'p': 'ट', 'P': 'ठ', '[': 'ड', '{': 'ढ',
|
|
35
|
+
't': 'त', 'T': 'थ', 'M': 'न',
|
|
36
|
+
'b': 'प', 'B': 'फ', 'y': 'ब', 'Y': 'भ', 'm': 'म',
|
|
37
|
+
'r': 'य', 'R': 'य', 'l': 'र', 'L': 'ल', 'v': 'व',
|
|
38
|
+
'W': 'श', ';': 'ष', 'Z': 'स', '\'': 'ह',
|
|
39
|
+
'`': 'ऱ', '~': 'ज़', '&': 'ड़', '*': 'ढ़', '#': 'ख़', '@': 'ग़',
|
|
40
|
+
|
|
41
|
+
// Numbers
|
|
42
|
+
'0': '०', '1': '१', '2': '२', '3': '३', '4': '४',
|
|
43
|
+
'5': '५', '6': '६', '7': '७', '8': '८', '9': '९',
|
|
44
|
+
|
|
45
|
+
// Danda
|
|
46
|
+
'.': '।', '..': '॥'
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Conjunct mappings
|
|
50
|
+
this.conjunctMap = {
|
|
51
|
+
'kz': 'क्ष', 'Kz': 'क्ष', 'tr': 'त्र', 'Tr': 'त्र',
|
|
52
|
+
'gn': 'ज्ञ', 'gy': 'ज्ञ', 'Gn': 'ज्ञ', 'Wr': 'श्र',
|
|
53
|
+
'[y': 'ड्य', 'ty': 'त्य', 'Dy': 'ध्य', 'Wy': 'श्य',
|
|
54
|
+
'dy': 'द्य', 'My': 'न्य', 'hy': 'ज्य', 'by': 'प्य',
|
|
55
|
+
'my': 'म्य', 'yy': 'ब्य', 'Zt': 'स्त', 'Zb': 'स्प',
|
|
56
|
+
'Zk': 'स्क', ';t': 'ष्ट', ';T': 'ष्ठ'
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Convert Preeti text to Unicode Devanagari
|
|
62
|
+
*/
|
|
63
|
+
convert(preetiText) {
|
|
64
|
+
if (!preetiText) return '';
|
|
65
|
+
let unicodeText = '';
|
|
66
|
+
let i = 0;
|
|
67
|
+
|
|
68
|
+
while (i < preetiText.length) {
|
|
69
|
+
if (i + 1 < preetiText.length && preetiText.substring(i, i + 2) === '..') {
|
|
70
|
+
unicodeText += this.preetiMap['..'];
|
|
71
|
+
i += 2;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (i + 1 < preetiText.length) {
|
|
76
|
+
const twoChar = preetiText.substring(i, i + 2);
|
|
77
|
+
if (this.conjunctMap[twoChar]) {
|
|
78
|
+
unicodeText += this.conjunctMap[twoChar];
|
|
79
|
+
i += 2;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const char = preetiText[i];
|
|
85
|
+
if (this.preetiMap[char]) {
|
|
86
|
+
unicodeText += this.preetiMap[char];
|
|
87
|
+
} else {
|
|
88
|
+
unicodeText += char;
|
|
89
|
+
}
|
|
90
|
+
i++;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return unicodeText;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Batch convert multiple texts
|
|
98
|
+
*/
|
|
99
|
+
convertBatch(texts) {
|
|
100
|
+
return texts.map(text => this.convert(text));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Add custom character mapping
|
|
105
|
+
*/
|
|
106
|
+
addCustomMapping(preetiChar, unicodeChar) {
|
|
107
|
+
this.preetiMap[preetiChar] = unicodeChar;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Add custom conjunct mapping
|
|
112
|
+
*/
|
|
113
|
+
addCustomConjunct(preetiConjunct, unicodeConjunct) {
|
|
114
|
+
this.conjunctMap[preetiConjunct] = unicodeConjunct;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get all mappings
|
|
119
|
+
*/
|
|
120
|
+
getMappings() {
|
|
121
|
+
return {
|
|
122
|
+
characters: this.preetiMap,
|
|
123
|
+
conjuncts: this.conjunctMap
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Get mapping for a specific character
|
|
129
|
+
*/
|
|
130
|
+
getMapping(char) {
|
|
131
|
+
return this.preetiMap[char] || null;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Reverse convert (Unicode to Preeti)
|
|
136
|
+
*/
|
|
137
|
+
reverseConvert(unicodeText) {
|
|
138
|
+
if (!unicodeText) return '';
|
|
139
|
+
const reverseMap = {};
|
|
140
|
+
for (const [key, value] of Object.entries(this.preetiMap)) {
|
|
141
|
+
reverseMap[value] = key;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
let preetiText = '';
|
|
145
|
+
for (const char of unicodeText) {
|
|
146
|
+
preetiText += reverseMap[char] || char;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return preetiText;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Export for different module systems
|
|
154
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
155
|
+
module.exports = PreetiConverter;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (typeof exports !== 'undefined') {
|
|
159
|
+
exports.PreetiConverter = PreetiConverter;
|
|
160
|
+
}
|