aboutsummaryrefslogtreecommitdiff
path: root/src/lib/_str.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/_str.rs')
-rw-r--r--src/lib/_str.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/lib/_str.rs b/src/lib/_str.rs
index 062d8bf1..8eed9a38 100644
--- a/src/lib/_str.rs
+++ b/src/lib/_str.rs
@@ -12,6 +12,18 @@ fn is_utf8(vec[u8] v) -> bool {
fail; // FIXME
}
+fn is_ascii(str s) -> bool {
+ let uint i = len(s);
+ while (i > 0u) {
+ i -= 1u;
+ // FIXME (issue #94)
+ if ((s.(i as int) & 0x80u8) != 0u8) {
+ ret false;
+ }
+ }
+ ret true;
+}
+
fn alloc(uint n_bytes) -> str {
ret rustrt.str_alloc(n_bytes);
}
@@ -23,3 +35,10 @@ fn len(str s) -> uint {
fn buf(str s) -> sbuf {
ret rustrt.str_buf(s);
}
+
+fn bytes(&str s) -> vec[u8] {
+ fn ith(str s, uint i) -> u8 {
+ ret s.(i as int); // FIXME (issue #94)
+ }
+ ret _vec.init_fn[u8](bind ith(s, _), _str.len(s));
+}