=================================
=================================
=================================

출처: http://jhun88.tistory.com/entry/UTF-8-EUC-KR
갤탭 개발하면서 인코딩 부분때문에 애먹었다. 대부분 서버파트에서는 EUC-KR를 통해 인코딩되어 있고 로컬에서는 utf-8를 주로 사용하기 때문에 서버에 등록하거나 가져올때는 적절한 인코딩을 해주어야 한다.
|
1
2
3
4
5
6
7
8
|
try{ groupName = new String(currentGroup.groupName.getBytes(), "utf-8");}catch(UnsupportedEncodingException e){ if(AppMgr.DEBUGMODE) CommonUtil.ShowMessageBox("인코딩실패", null); return;} |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
String boowak = "boowak";byte[] groupName = new byte[30]; try{ Charset b = Charset.forName("euc-kr"); CharsetEncoder encoder = b.newEncoder(); CharsetDecoder decoder = b.newDecoder(); ByteBuffer bb = encoder.encode(CharBuffer.wrap(boowak)); byte[] c = new byte[bb.remaining()]; bb.get(c); System.arraycopy(c, 0, groupName, 0, c.length); } catch (CharacterCodingException e) { System.out.println("encoding and decoding failed"); return; } |
///////////////////////////////////////////////////////////////////////////////////////////////////////
db 만들기 위해 문자열을 txt 파일에서 가져올때 ksc5601로 지정해 주니까 문제가 해결되었습니다.
String filename = "/sdcard/make.txt";
File file = new File(filename);
FileInputStream secFile = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(secFile, "KSC5601"));
...
strLine = br.readLine();
values.put(MDBSECTIONCNT, strLine);
...
=================================
=================================
=================================
'스마트기기개발관련 > 안드로이드 개발' 카테고리의 다른 글
| 안드로이드 수평 스크롤뷰~ (0) | 2011.07.14 |
|---|---|
| 안드로이드 이미지 뷰어 멀티 터치 줌 관련 (2) | 2011.07.14 |
| 안드로이드 영문 키보드 나오게 하기 관련 (0) | 2011.07.13 |
| 안드로이드 아이콘 사이즈 관련 (0) | 2011.07.13 |
| 안드로이드 버전정보 추출!! (0) | 2011.07.13 |