1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2014-09-01 00:43:52 -04:00
parent b0a01882de
commit be63adc5af
125 changed files with 1859 additions and 952 deletions

View File

@@ -36,6 +36,10 @@ public class Int_ implements GfoInvkAble {
rv[i] = ary[i];
return rv;
}
public static void Ary_copy_to(int[] src, int src_len, int[] trg) {
for (int i = 0; i < src_len; ++i)
trg[i] = src[i];
}
public static int[] AryRng(int bgn, int end) {
int len = end - bgn + 1;
int[] rv = new int[len];

View File

@@ -26,8 +26,10 @@ public class Io_url implements CompareAble, EqAble, ParseAble, GfoInvkAble { //_
// catch (Exception e) {throw Err_.err_(e, "Http_file_bry");}
// }
public String To_http_file_str() {return Http_file_str + Http_file_str_encoder.Encode_str(raw);}
public byte[] To_http_file_bry() {return Bry_.Add(Http_file_bry, Http_file_str_encoder.Encode_bry(raw));}
public static Url_encoder_interface Http_file_str_encoder;
public byte[] To_http_file_bry() {
return Bry_.Add(Http_file_bry, Http_file_str_encoder.Encode_bry(raw));
}
public static Url_encoder_interface Http_file_str_encoder = Url_encoder_interface_same._;
public static final String Http_file_str = "file:///";
public static final int Http_file_len = String_.Len(Http_file_str);

View File

@@ -20,3 +20,8 @@ public interface Url_encoder_interface {
String Encode_str(String v);
byte[] Encode_bry(String v);
}
class Url_encoder_interface_same implements Url_encoder_interface {
public String Encode_str(String v) {return v;}
public byte[] Encode_bry(String v) {return Bry_.new_utf8_(v);}
public static final Url_encoder_interface_same _ = new Url_encoder_interface_same(); Url_encoder_interface_same() {}
}

View File

@@ -40,6 +40,25 @@ public class Yn {
return v_int == Bool_.Y_int;
}
public static String Xto_str(boolean v) {return v ? "y" : "n";}
public static String Xto_nullable_str(byte v) {
switch (v) {
case Bool_.Y_byte: return "y";
case Bool_.N_byte: return "n";
case Bool_.__byte: return "?";
default: throw Err_.unhandled(v);
}
}
public static byte Xto_nullable_byte(String v) {
if (v != null && String_.Len(v) == 1) {
char c = String_.CharAt(v, 0);
switch (c) {
case 'y': return Bool_.Y_byte;
case 'n': return Bool_.N_byte;
case '?': return Bool_.__byte;
}
}
throw Err_.unhandled(v);
}
public static boolean store_bool_or(SrlMgr mgr, String key, boolean or) {
String v = mgr.SrlStrOr(key, "");
return mgr.Type_rdr() ? parse_or_(v, or) : or;

View File

@@ -17,6 +17,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gplx.intl; import gplx.*;
public class Utf8_ {
public static int Len_of_bry(byte[] ary) {
if (ary == null) return 0;
int rv = 0;
int pos = 0, len = ary.length;
while (pos < len) {
int char_len = Len_of_char_by_1st_byte(ary[pos]);
++rv;
pos += char_len;
}
return rv;
}
public static int Len_of_char_by_1st_byte(byte b) {// SEE:w:UTF-8
int i = b & 0xff; // PATCH.JAVA:need to convert to unsigned byte
switch (i) {