PageSourceSearch

https://kovihouse.ai/resources/js/language/changeLanguage.js

js kovihouse.ai collected 2026-10-05 12:09:20 UTC 10,979 bytes, 321 lines download raw bytes

1// Case 정리
2	// --------- 1 글자 ----------
3	// 1. ㄱ : 자음 
4	// 2. ㅏ : 모음
5	// --------- 2 글자 ----------
6	// 3. 자음 + 자음 : ㄺ
7	// 4. 자음 + 모음 : 가
8	// x. 모음 + 자음 : ㅗㄱ 
9	// 5. 모음 + 모음 : ㅚ 
10	// --------- 3 글자 ----------
11	// x. 자음 + 자음 + 자음 : ㄱㄱㄱ/ㄺㄱ/ㄱㄺ
12	// x. 자음 + 자음 + 모음 : ㄹ가
13	// 6. 자음 + 모음 + 자음 : 간
14	// 7. 자음 + 모음 + 모음 : 과/가ㅏ
15	// x. 모음 + 자음 + 자음 : ㅗㄱㄹ/ㅇㄺ
16	// x. 모음 + 자음 + 모음 : ㅗ고
17	// x. 모음 + 모음 + 자음 : ㅚㄱ/ㅏㅏㄱ
18	// x. 모음 + 모음 + 모음 : ㅏㅏㅏ/ㅚㅏ/ㅏㅚ
19	// --------- 4 글자 ----------
20	// 8. 자음 + 모음 + 자음 + 자음 : 닭
21	// 9. 자음 + 모음 + 모음 + 자음 : 관
22	// --------- 5 글자 ----------
23	// 10. 자음 + 모음 + 모음 + 자음 + 자음 : 괅 
24	var 영어타이핑 = "rRseEfaqQtTdwWczxvgkoiOjpuPhynbml";
25	var 한글타이핑 = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎㅏㅐㅑㅒㅓㅔㅕㅖㅗㅛㅜㅠㅡㅣ";
26	var 초성모음 = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ";
27	var 중성모음 = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ";
28	var 종성모음 = "ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ";
29	function 한글조합하기(src) {
30	  if (src == null) {
31	    return '';
32	  }
33	  var result = {
34	    사용한글자수 : src.length
35	  }
36	  switch (src.length) {
37	  case 0:
38	    result.조합된한글 = src;
39	    break;
40	  case 1: // case 1,2
41	    result.조합된한글 = convert영한(src);
42	    break;
43	  case 2: // case 3,4,5
44	    var ch1 = src.charAt(0), ch2 = src.charAt(1);
45	    // 3. 자음 + 자음 : ㄺ
46	    if (is자음(ch1) && is자음(ch2)) {
47	      var 결합자음 = 자음결합하기(convert영한(ch1), convert영한(ch2));
48	      if (결합자음) {
49	        result.조합된한글 = 결합자음;
50	      } else {
51	        result = 한글조합하기(src.substring(1, 2));
52	      }
53	    }
54	    // 4. 자음 + 모음 : 가
55	    else if (is자음(ch1) && is모음(ch2)) {
56	      result.조합된한글 = combine한글(convert영한(ch1), convert영한(ch2));
57	    }
58	    // 5. 모음 + 모음 : ㅚ
59	    else if (is모음(ch1) && is모음(ch2)) {
60	      var 결합모음 = 모음결합하기(convert영한(ch1), convert영한(ch2));
61	      if (결합모음) {
62	        result.조합된한글 = 결합모음;
63	      } else {
64	        result = 한글조합하기(src.substring(1, 2));
65	      }
66	    } else {
67	      result = 한글조합하기(src.substring(1, 2));
68	    }
69	    break;
70	  case 3:// case 6, 7
71	    var ch1 = src.charAt(0), ch2 = src.charAt(1), ch3 = src.charAt(2);
72	    // 6. 자음 + 모음 + 자음 : 간
73	    if (is자음(ch1) && is모음(ch2) && is자음(ch3)) {
74	      result.조합된한글 = combine한글(convert영한(ch1), convert영한(ch2), convert영한(ch3));
75	    }
76	    // 7. 자음 + 모음 + 모음 : 과
77	    else if (is자음(ch1) && is모음(ch2) && is모음(ch3)) {
78	      var 결합모음 = 모음결합하기(convert영한(ch2), convert영한(ch3));
79	      if (결합모음) {
80	        result.조합된한글 = combine한글(convert영한(ch1), 결합모음);
81	      } else {
82	        result = 한글조합하기(src.substring(1, 3));
83	      }
84	    } else {
85	      result = 한글조합하기(src.substring(1, 3));
86	    }
87	    break;
88	  case 4:// 
89	    var ch1 = src.charAt(0), ch2 = src.charAt(1), ch3 = src.charAt(2), ch4 = src.charAt(3);
90	    // 8. 자음 + 모음 + 자음 + 자음 : 닭
91	    if (is자음(ch1) && is모음(ch2) && is자음(ch3) && is자음(ch4)) {
92	      var 결합자음 = 자음결합하기(convert영한(ch3), convert영한(ch4));
93	      if (결합자음) {
94	        result.조합된한글 = combine한글(convert영한(ch1), convert영한(ch2), 결합자음);
95	      } else {
96	        result = 한글조합하기(src.substring(1, 4));
97	      }
98	    }
99	    // 9. 자음 + 모음 + 모음 + 자음 : 관
100	    else if (is자음(ch1) && is모음(ch2) && is모음(ch3) && is자음(ch4)) {
101	      var 결합모음 = 모음결합하기(convert영한(ch2), convert영한(ch3));
102	      if (결합모음) {
103	        result.조합된한글 = combine한글(convert영한(ch1), 결합모음, convert영한(ch4));
104	      } else {
105	        result = 한글조합하기(src.substring(1, 4));
106	      }
107	    } else {
108	      result = 한글조합하기(src.substring(1, 4));
109	    }
110	    break;
111	  case 5:// 
112	    var ch1 = src.charAt(0), ch2 = src.charAt(1), ch3 = src.charAt(2), ch4 = src.charAt(3), ch5 = src.charAt(4);
113	    // 자음 + 모음 + 모음 + 자음 + 자음 : 괅
114	    if (is자음(ch1) && is모음(ch2) && is모음(ch3) && is자음(ch4) && is자음(ch5)) {
115	      var 결합모음 = 모음결합하기(convert영한(ch2), convert영한(ch3));
116	      var 결합자음 = 자음결합하기(convert영한(ch4), convert영한(ch5));
117	      if (결합모음 && 결합자음) {
118	        result.조합된한글 = combine한글(convert영한(ch1), 결합모음, 결합자음);
119	      } else {
120	        result = 한글조합하기(src.substring(1, 5));
121	      }
122	    } else {
123	      result = 한글조합하기(src.substring(1, 5));
124	    }
125	    break;
126	  }
127	  return result;
128	}
129	function korToEng(src) {
130	  var res = "";
131	  if (src.length == 0) {
132	    return res;
133	  }
134	  for (var i = 0; i < src.length; i++) {
135	    var ch = src.charAt(i);
136	    var nCode = ch.charCodeAt(0);
137	    var result = '';
138	    var 초성, 중성, 종성;
139	    if (44032 <= nCode && nCode <= 55203) {
140	      nCode -= 44032;
141	      초성 = 초성모음.charAt(Math.floor(nCode / (21 * 28)));
142	      중성 = 중성모음.charAt(Math.floor(nCode / 28) % 21);
143	      종성 = 종성모음.charAt(nCode % 28 - 1);
144	      res += convert한영(초성);
145	      var 모음분해 = 모음분해하기(중성);
146	      if (모음분해) {
147	        res += convert한영(모음분해);
148	      } else {
149	        res += convert한영(중성);
150	      }
151	      var 자음분해 = 자음분해하기(종성);
152	      if (자음분해) {
153	        res += convert한영(자음분해);
154	      } else {
155	        res += convert한영(종성);
156	      }
157	    } else if (초성모음.indexOf(ch) > -1) {
158	      res += convert한영(ch);
159	    } else if (중성모음.indexOf(ch) > -1) {
160	      var 모음분해 = 모음분해하기(ch);
161	      if (모음분해) {
162	        res += convert한영(모음분해);
163	      } else {
164	        res += convert한영(ch);
165	      }
166	    } else if (종성모음.indexOf(ch) > -1) {
167	      var 자음분해 = 자음분해하기(ch);
168	      if (자음분해) {
169	        res += convert한영(자음분해);
170	      } else {
171	        res += convert한영(ch);
172	      }
173	    } else {
174	      res += ch;
175	    }
176	  }
177	  return res;
178	}
179	function convert영한(src) {
180	  var result = '';
181	  for (var i = 0; i < src.length; i++) {
182	    var ch = src.charAt(i);
183	    var index = 영어타이핑.indexOf(ch);
184	    if (index >= 0) {
185	      result += 한글타이핑.charAt(index);
186	    } else {
187	      result += ch;
188	    }
189	  }
190	  return result;
191	}
192	function convert한영(src) {
193	  var result = '';
194	  for (var i = 0; i < src.length; i++) {
195	    var ch = src.charAt(i);
196	    var index = 한글타이핑.indexOf(ch);
197	    if (index >= 0) {
198	      result += 영어타이핑.charAt(index);
199	    } else {
200	      result += ch;
201	    }
202	  }
203	  return result;
204	}
205	function is영어타이핑(ch) {
206	  return 영어타이핑.indexOf(ch) >= 0;
207	}
208	function is모음(ch) {
209	  return 영어타이핑.indexOf(ch) >= 19;
210	}
211	function is자음(ch) {
212	  return 영어타이핑.indexOf(ch) < 19 && 영어타이핑.indexOf(ch) >= 0;
213	}
214	function engToKor(src) {
215	  var res = "";
216	  if (src.length == 0)
217	    return res;
218	  var 초성위치 = -1, 중성위치 = -1, 종성위치 = -1; // 초성, 중성, 종성
219	  for (var i = 0; i < src.length; i++) {
220	    var result = 한글조합하기(src.slice(Math.max(src.length - 5 - i, 0), src.length - i));
221	    // console.log(result);
222	    i += result.사용한글자수 - 1;
223	    res = result.조합된한글 + res;
224	  }
225	  return res;
226	}
227	function combine한글(초성, 중성, 종성) {
228	  return String.fromCharCode(44032 + 초성모음.indexOf(초성) * 21 * 28 + 중성모음.indexOf(중성) * 28 + 종성모음.indexOf(종성) + 1);
229	}
230	function 모음결합하기(ch1, ch2) {
231	  var result = null;
232	  if (ch1 == 'ㅗ' && ch2 == 'ㅏ') { // ㅘ
233	    result = 'ㅘ';
234	  } else if (ch1 == 'ㅗ' && ch2 == 'ㅐ') { // ㅙ
235	    result = 'ㅙ';
236	  } else if (ch1 == 'ㅗ' && ch2 == 'ㅣ') { // ㅚ
237	    result = 'ㅚ';
238	  } else if (ch1 == 'ㅜ' && ch2 == 'ㅓ') { // ㅝ
239	    result = 'ㅝ';
240	  } else if (ch1 == 'ㅜ' && ch2 == 'ㅔ') { // ㅞ
241	    result = 'ㅞ';
242	  } else if (ch1 == 'ㅜ' && ch2 == 'ㅣ') { // ㅟ
243	    result = 'ㅟ';
244	  } else if (ch1 == 'ㅡ' && ch2 == 'ㅣ') { // ㅢ
245	    result = 'ㅢ';
246	  }
247	  return result;
248	}
249	function 모음분해하기(ch) {
250	  switch (ch) {
251	  case 'ㅘ':
252	    return 'ㅗㅏ';
253	  case 'ㅙ':
254	    return 'ㅗㅐ';
255	  case 'ㅚ':
256	    return 'ㅗㅣ';
257	  case 'ㅝ':
258	    return 'ㅜㅓ';
259	  case 'ㅞ':
260	    return 'ㅜㅔ';
261	  case 'ㅟ':
262	    return 'ㅜㅣ';
263	  case 'ㅢ':
264	    return 'ㅡㅣ';
265	  }
266	  return null;
267	}
268	function 자음결합하기(ch1, ch2) {
269	  var result = null;
270	  if (ch1 == 'ㄱ' && ch2 == 'ㅅ') { // ㄳ
271	    result = 'ㄳ';
272	  } else if (ch1 == 'ㄴ' && ch2 == 'ㅈ') { // ㄵ
273	    result = 'ㄵ';
274	  } else if (ch1 == 'ㄴ' && ch2 == 'ㅎ') { // ㄶ
275	    result = 'ㄶ';
276	  } else if (ch1 == 'ㄹ' && ch2 == 'ㄱ') { // ㄺ
277	    result = 'ㄺ';
278	  } else if (ch1 == 'ㄹ' && ch2 == 'ㅁ') { // ㄻ
279	    result = 'ㄻ';
280	  } else if (ch1 == 'ㄹ' && ch2 == 'ㅂ') { // ㄼ
281	    result = 'ㄼ';
282	  } else if (ch1 == 'ㄹ' && ch2 == 'ㅅ') { // ㄽ
283	    result = 'ㄽ';
284	  } else if (ch1 == 'ㄹ' && ch2 == 'ㅌ') { // ㄾ
285	    result = 'ㄾ';
286	  } else if (ch1 == 'ㄹ' && ch2 == 'ㅍ') { // ㄿ
287	    result = 'ㄿ';
288	  } else if (ch1 == 'ㄹ' && ch2 == 'ㅎ') { // ㅀ
289	    result = 'ㅀ';
290	  } else if (ch1 == 'ㅂ' && ch2 == 'ㅅ') { // ㅄ
291	    result = 'ㅄ';
292	  }
293	  return result;
294	}
295	function 자음분해하기(ch) {
296	  switch (ch) {
297	  case 'ㄳ':
298	    return 'ㄱㅅ';
299	  case 'ㄵ':
300	    return 'ㄴㅈ';
301	  case 'ㄶ':
302	    return 'ㄴㅎ';
303	  case 'ㄺ':
304	    return 'ㄹㄱ';
305	  case 'ㄻ':
306	    return 'ㄹㅁ';
307	  case 'ㄼ':
308	    return 'ㄹㅂ';
309	  case 'ㄽ':
310	    return 'ㄹㅅ';
311	  case 'ㄾ':
312	    return 'ㄹㅌ';
313	  case 'ㄿ':
314	    return 'ㄹㅍ';
315	  case 'ㅀ':
316	    return 'ㄹㅎ';
317	  case 'ㅄ':
318	    return 'ㅂㅅ';
319	  }
320	  return null;
321	}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.