-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImportUTF8Emojis.cs
37 lines (30 loc) · 1.14 KB
/
ImportUTF8Emojis.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using Interop = Microsoft.Office.Interop.Word;
using System.Runtime.InteropServices;
using System.IO;
using System.Windows;
public class ImportEmojis
{
public static int Main (String[] args) {
try {
Interop.Application Word = new Interop.Application();
Console.OutputEncoding = System.Text.Encoding.UTF8;
// read emoji file
StreamReader streamreader = new StreamReader(args[0]);
char[] delimiter = new char[] { '\t' };
while (streamreader.Peek() > 0)
{
string[] rowcolumn = streamreader.ReadLine().Split(delimiter);
Console.WriteLine("Adding {0}\t{1}", rowcolumn[0], rowcolumn[1]);
Word.AutoCorrect.Entries.Add(rowcolumn[0], rowcolumn[1]); // set AutoCorrectEntries
}
streamreader.Close();
System.Runtime.InteropServices.Marshal.ReleaseComObject(Word);
return 0;
}
catch(Exception ex) {
Console.Error.WriteLine("[ERROR] {0}", ex.Message);
return -1;
}
}
}