Utf8

Utf8

package haxe

Available on all platforms

Since not all platforms guarantee that String always uses UTF-8 encoding, you can use this crossplatform API to perform operations on such strings.

Constructor

new (?size:Int)

Allocate a new Utf8 buffer using an optional bytes size.

Methods

addChar (c:Int):Void

Add the given UTF8 character code to the buffer.

toString ():String

Returns the buffer converted to a String.

Static methods

static char (unicode:Int):String

Available on lua

static charCodeAt (s:String, index:Int):Int

Similar to String.charCodeAt but uses the UTF8 character position.

static compare (a:String, b:String):Int

Compare two UTF8 strings, character by character.

static decode (s:String):String

Decode an UTF8 string back to an ISO string. Throw an exception if a given UTF8 character is not supported by the decoder.

static encode (s:String):String

Encode the input ISO string into the corresponding UTF8 one.

static iter (s:String, chars:Int ‑> Void):Void

Call the chars function for each UTF8 char of the string.

static length (s:String):Int

Returns the number of UTF8 chars of the String.

static sub (s:String, pos:Int, len:Int):String

This is similar to String.substr but the pos and len parts are considering UTF8 characters.

static validate (s:String):Bool

Tells if the String is correctly encoded as UTF8.

© 2005–2016 Haxe Foundation
Licensed under a MIT license.
http://api.haxe.org/haxe/Utf8.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部