-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
184 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
support/src/main/java/net/avenwu/support/util/ChartSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.avenwu.support.util; | ||
|
||
import android.util.Log; | ||
|
||
/** | ||
* Created by chaobin on 11/22/15. | ||
*/ | ||
public class ChartSet { | ||
|
||
static final String TAG = ChartSet.class.getCanonicalName(); | ||
final static char ANSI_START = '!'; | ||
final static char ANSI_END = '~'; | ||
|
||
final static char UNICODE_START = '!'; | ||
final static char UNICODE_END = '~'; | ||
|
||
final static long DIFF = UNICODE_START - ANSI_START; | ||
|
||
public static String convertDBCS(CharSequence text) { | ||
StringBuilder builder = new StringBuilder(); | ||
for (int i = 0; i < text.length(); i++) { | ||
char c = text.charAt(i); | ||
Log.e(TAG, "" + c); | ||
if (isCharNeedConvert(c)) { | ||
c = convert(c); | ||
Log.e(TAG, "translated:" + c); | ||
} | ||
builder.append(c); | ||
} | ||
return builder.toString(); | ||
} | ||
|
||
public static boolean isCharNeedConvert(char c) { | ||
return c >= UNICODE_START && c <= UNICODE_END; | ||
} | ||
|
||
public static char convert(char c) { | ||
return (char) (c - DIFF); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters