Comments (6)
change function toZenkakuCase to following code:
public static String toZenkakuCase(String str)
{
int f = str.length();
StringBuilder buffer = new StringBuilder(str);
for(int i=0;i<f;i++)
{
char c = str.charAt(i);
if(H2Z.containsKey(c)){
buffer.setCharAt(i, H2Z.get(c));
} else if(c == 0x0020){
buffer.setCharAt(i, '\u3000');
} else if(c <= 0x007E && 0x0021 <= c) {
buffer.setCharAt(i, (char)(c + 0xFEE0));
}
}
str=buffer.toString();
f = str.length();
buffer = new StringBuilder(str);
for(int i=0;i<f;i++)
{
char c = str.charAt(i);
if ((0x304B <= c && c <= 0x3062 && (c % 2 == 1)) ||
(0x30AB <= c && c <= 0x30C2 && (c % 2 == 1)) ||
(0x3064 <= c && c <= 0x3069 && (c % 2 == 0)) ||
(0x30C4 <= c && c <= 0x30C9 && (c % 2 == 0))) {
char d = buffer.charAt(i + 1);
buffer.setCharAt(i, (char) (c + ((d == '\u309B') ? 1 : 0)));
if (c != buffer.charAt(i)) {
buffer = buffer.deleteCharAt(i + 1);
f--;
}
continue;
}
if ((0x306F <= c && c <= 0x307D && (c % 3 == 0)) ||
(0x30CF <= c && c <= 0x30DD && (c % 3 == 0))) {
char d = buffer.charAt(i + 1);
buffer.setCharAt(i, (char) (c + ((d == '\u309B') ? 1 : ((d == '\u309C') ? 2 : 0))));
if (c != buffer.charAt(i)) {
buffer = buffer.deleteCharAt(i + 1);
f--;
}
continue;
}
}
return buffer.toString();
};
from kanaxs.
あと追加です。すみません。
「ャ」「ュ」「ョ」が半角になってくれませんです。as3版です。
from kanaxs.
Thanks for the correction!
from kanaxs.
すみません、先週のcodeを改修した後で、新しbugを見えました。
再改修した:
public static String toZenkakuCase(String str)
{
int f = str.length();
StringBuilder buffer = new StringBuilder(str);
for(int i=0;i<f;i++)
{
char c = str.charAt(i);
if(H2Z.containsKey(c)){
buffer.setCharAt(i, H2Z.get(c));
} else if(c == 0x0020){
buffer.setCharAt(i, '\u3000');
} else if(c <= 0x007E && 0x0021 <= c) {
buffer.setCharAt(i, (char)(c + 0xFEE0));
}
}
str=buffer.toString();
f = str.length();
buffer = new StringBuilder(str);
for(int i=0;i<f;i++)
{
char c = str.charAt(i);
if ((0x304B <= c && c <= 0x3062 && (c % 2 == 1)) ||
(0x30AB <= c && c <= 0x30C2 && (c % 2 == 1)) ||
(0x3064 <= c && c <= 0x3069 && (c % 2 == 0)) ||
(0x30C4 <= c && c <= 0x30C9 && (c % 2 == 0))) {
if(i + 1 < buffer.length()){
char d = buffer.charAt(i + 1);
buffer.setCharAt(i, (char) (c + ((d == '\u309B') ? 1 : 0)));
if (c != buffer.charAt(i)) {
buffer = buffer.deleteCharAt(i + 1);
f--;
}
continue;
}
}
if ((0x306F <= c && c <= 0x307D && (c % 3 == 0)) ||
(0x30CF <= c && c <= 0x30DD && (c % 3 == 0))) {
if(i + 1 < buffer.length()){
char d = buffer.charAt(i + 1);
buffer.setCharAt(i, (char) (c + ((d == '\u309B') ? 1 : ((d == '\u309C') ? 2 : 0))));
if (c != buffer.charAt(i)) {
buffer = buffer.deleteCharAt(i + 1);
f--;
}
continue;
}
}
}
return buffer.toString();
};
from kanaxs.
Thank you. I will use the new version.
from kanaxs.
“if(i + 1 < buffer.length()){”を追加しました
from kanaxs.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kanaxs.