<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ocr.michiyo.me/w/index.php?action=history&amp;feed=atom&amp;title=API%2Funicode</id>
	<title>API/unicode - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ocr.michiyo.me/w/index.php?action=history&amp;feed=atom&amp;title=API%2Funicode"/>
	<link rel="alternate" type="text/html" href="https://ocr.michiyo.me/w/index.php?title=API/unicode&amp;action=history"/>
	<updated>2026-08-24T13:44:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>https://ocr.michiyo.me/w/index.php?title=API/unicode&amp;diff=1060&amp;oldid=prev</id>
		<title>imported&gt;OCDoc Import: Imported from legacy OpenComputers documentation at ocdoc.cil.li</title>
		<link rel="alternate" type="text/html" href="https://ocr.michiyo.me/w/index.php?title=API/unicode&amp;diff=1060&amp;oldid=prev"/>
		<updated>2026-08-24T08:08:27Z</updated>

		<summary type="html">&lt;p&gt;Imported from legacy OpenComputers documentation at ocdoc.cil.li&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Unicode API =&lt;br /&gt;
&lt;br /&gt;
Because all strings pass through Java at some point it can be useful to handle them with Unicode support (since Java&amp;#039;s internal string representation is UTF-8 encoded). In particular, screens display UTF-8 strings, meaning the related GPU functions expect UTF-8 strings. Also, keyboard input will generally be UTF-8 encoded, especially the clipboard.&lt;br /&gt;
&lt;br /&gt;
However, keep in mind that while wide characters can be displayed, input and output of those is not fully supported in OpenOS&amp;#039;s software (i.e. the shell, edit and Lua interpreter).&lt;br /&gt;
&lt;br /&gt;
The following functions are provided to allow basic UTF-8 handling:&lt;br /&gt;
&lt;br /&gt;
* `unicode.char(value: number, ...): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;UTF-8 aware version of `string.char`. The values may be in the full UTF-8 range, not just ASCII.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.charWidth(value: string, ...): number`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Returns the width of the first character given. For example, for `シ` it&amp;#039;ll return `2`, where `a` would return `1`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.isWide(value: string, ...): boolean`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Returns if the width of the first character given is greater than 1. For example, for `シ` it&amp;#039;ll return `true`, where `a` would return `false`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.len(value: string): number`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;UTF-8 aware version of `string.len`. For example, for `Ümläüt` it&amp;#039;ll return `6`, where `string.len` would return `9`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.lower(value: string): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;UTF-8 aware version of `string.lower`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.reverse(value: string): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;UTF-8 aware version of `string.reverse`. For example, for `Ümläüt` it&amp;#039;ll return `tüälmÜ`, where `string.reverse` would return `tälm`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.sub(value: string, i:number[, j:number]): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;UTF-8 aware version of `string.sub`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.upper(value: string): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;UTF-8 aware version of `string.upper`.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.wlen(value: string): number`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Returns the width of the entire string.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* `unicode.wtrunc(value: string, count: number): string`&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Truncates the given string up to but not including `count` width. If there are not enough characters to match the wanted width, the function errors.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For example, these are used when files are opened in non-binary mode. The original string functions are used for files opened in binary mode.&lt;br /&gt;
&lt;br /&gt;
== Contents ==&lt;br /&gt;
&lt;br /&gt;
{{:API/contents}}&lt;br /&gt;
&lt;/div&gt;</summary>
		<author><name>imported&gt;OCDoc Import</name></author>
	</entry>
</feed>