mirror of
https://github.com/denoland/deno.git
synced 2024-11-27 16:10:57 -05:00
8f2d171404
Fixes: https://github.com/denoland/deno/issues/23657 Implements `isUtf8` and `isAscii` as ops.
13 lines
281 B
Rust
13 lines
281 B
Rust
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use deno_core::op2;
|
|
|
|
#[op2(fast)]
|
|
pub fn op_is_ascii(#[buffer] buf: &[u8]) -> bool {
|
|
buf.is_ascii()
|
|
}
|
|
|
|
#[op2(fast)]
|
|
pub fn op_is_utf8(#[buffer] buf: &[u8]) -> bool {
|
|
std::str::from_utf8(buf).is_ok()
|
|
}
|