The UTF-8 encoding is the most appropriate encoding for interchange of Unicode, the universal coded character set. Therefore for new protocols and formats, as well as existing formats deployed in new contexts, this specification requires (and defines) the UTF-8 encoding.
The other (legacy) encodings have been defined to some extent in the past. However, user agents have not always implemented them in the same way, have not always used the same labels, and often differ in dealing with undefined and former proprietary areas of encodings. This specification addresses those gaps so that new user agents do not have to reverse engineer encoding implementations and existing user agents can converge.
In particular, this specification defines all those encodings, their algorithms to go from bytes to scalar values and back, and their canonical names and identifying labels. This specification also defines an API to expose part of the encoding algorithms to JavaScript.
User agents have also significantly deviated from the labels listed in the IANA Character Sets registry. To stop spreading legacy encodings further, this specification is exhaustive about the aforementioned details and therefore has no need for the registry. In particular, this specification does not provide a mechanism for extending any aspect of encodings.
There is a set of encoding security issues when the producer and consumer do not agree on the encoding in use, or on the way a given encoding is to be implemented. For instance, an attack was reported in 2011 where a Shift_JIS lead byte 0x82 was used to “mask” a 0x22 trail byte in a JSON resource of which an attacker could control some field. The producer did not see the problem even though this is an illegal byte combination. The consumer decoded it as a single U+FFFD and therefore changed the overall interpretation as U+0022 is an important delimiter. Decoders of encodings that use multiple bytes for scalar values now require that in case of an illegal byte combination, a scalar value in the range U+0000 to U+007F, inclusive, cannot be “masked”. For the aforementioned sequence the output would be U+FFFD U+0022.
This is a larger issue for encodings that map anything that is an ASCII byte to something that is not an ASCII code point, when there is no lead byte present. These are “ASCII-incompatible” encodings and other than ISO-2022-JP, UTF-16BE, and UTF-16LE, which are unfortunately required due to deployed content, they are not supported. (Investigation is ongoing whether more labels of other such encodings can be mapped to the replacement encoding, rather than the unknown encoding fallback.) An example attack is injecting carefully crafted content into a resource and then encouraging the user to override the encoding, resulting in e.g. script execution.
Encoders used by URLs found in HTML and HTML's form feature can also result in slight information loss when an encoding is used that cannot represent all scalar values. E.g. when a resource uses the windows-1252 encoding a server will not be able to distinguish between an end user entering “💩” and “💩” into a form.
The problems outlined here go away when exclusively using UTF-8, which is one of the many reasons that is now the mandatory encoding for all things.
See also the Browser UI chapter.
All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.
The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC2119. For readability, these words do not appear in all uppercase letters in this specification. RFC2119
Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)
User agents may impose implementation-specific limits on otherwise unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of memory, or to work around platform-specific limitations.
Hexadecimal numbers are prefixed with "0x".
In equations, all numbers are integers, addition is represented by "+", subtraction by "−", multiplication by "×", division by "/", calculating the remainder of a division (also known as modulo) by "%", logical left shifts by "<<", logical right shifts by ">>", bitwise AND by "&", and bitwise OR by "|". floor(x) is the largest integer not greater than x.
For logical right shifts operands must have at least twenty-one bits precision.
A byte is a sequence of eight bits, represented as a double-digit hexadecimal number in the range 0x00 to 0xFF, inclusive.
An ASCII byte is a byte in the range 0x00 to 0x7F, inclusive.
A code point is a Unicode code point and is represented as a four-to-six digit hexadecimal number, typically prefixed with "U+". In equations and indexes code points are prefixed with "0x". UNICODE
A scalar value is a code point that is not in the range U+D800 to U+DFFF, inclusive.
An ASCII code point is a code point in the range U+0000 to U+007F, inclusive.
The ASCII whitespace are code points U+0009, U+000A, U+000C, U+000D, and U+0020.
The ASCII digits are code points in the range U+0030 to U+0039, inclusive.
A string is a sequence of code points.
Comparing two strings in an ASCII case-insensitive manner means comparing them exactly, code point for code point, except that the characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z), inclusive, and the corresponding characters in the range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z), inclusive, are considered to also match.
To ASCII lowercase a string, replace all code points in the range U+0041 to U+005A, inclusive, with the corresponding code points in the range U+0061 to U+007A, inclusive.
A token is a piece of data, such as a byte or code point.
A stream represents an ordered sequence of tokens. End-of-stream is a special token that signifies no more tokens are in the stream.
When a token is read from a stream, the first token in the stream must be returned and subsequently removed, and end-of-stream must be returned otherwise.
When one or more tokens are prepended to a stream, those tokens must be inserted, in given order, before the first token in the stream.
Inserting the sequence of tokens 💩
in a
stream " hello world
", results in a stream
"💩 hello world
". The next token to be read would be
&
.
When one or more tokens are pushed to a stream, those tokens must be inserted, in given order, after the last token in the stream.
An encoding defines a mapping from a scalar value sequence to a byte sequence (and vice versa). Each encoding has a name, and one or more labels.
Each encoding has an associated decoder and most of them have an associated encoder. Each decoder and encoder have a handler algorithm. A handler algorithm takes an input stream and a token, and returns finished, one or more tokens, error optionally with a code point, or continue.
The replacement, UTF-16BE, and UTF-16LE encodings have no encoder.
An error mode as used below is "replacement
" (default) or
"fatal
" for a decoder and "fatal
" (default) or
"html
" for an encoder.
An XML processor would set error mode to "fatal
".
XML
"html
" exists as error mode due to URLs and HTML forms
requiring a non-terminating legacy encoder. The "html
"
error mode causes a sequence to be emitted that cannot be distinguished from
legitimate input and can therefore lead to silent data loss. Developers are strongly
encouraged to use the UTF-8 encoding to prevent this from
happening.
URL
HTML
To run an encoding's decoder or encoder encoderDecoder with input stream input, output stream output, and optional error mode mode, run these steps:
If mode is not given, set it to "replacement
", if
encoderDecoder is a decoder, and "fatal
" otherwise.
Let encoderDecoderInstance be a new encoderDecoder.
While true:
Let result be the result of processing the result of reading from input for encoderDecoderInstance, input, output, and mode.
If result is not continue, return result.
Otherwise, do nothing.
To process a token token for an encoding's encoder or decoder instance encoderDecoderInstance, stream input, output stream output, and optional error mode mode, run these steps:
If mode is not given, set it to "replacement
", if
encoderDecoderInstance is a decoder instance, and "fatal
"
otherwise.
Let result be the result of running encoderDecoderInstance's handler on input and token.
If result is continue or finished, return result.
Otherwise, if result is one or more tokens, push result to output.
Otherwise, if result is error, switch on mode and run the associated steps:
replacement
"
html
"
fatal
"
The table below lists all encodings and their labels user agents must support. User agents must not support any other encodings or labels.
Authors must use the UTF-8 encoding and must use the
ASCII case-insensitive "utf-8
" label to
identify it.
New protocols and formats, as well as existing formats deployed in new contexts, must
use the UTF-8 encoding exclusively. If these protocols and
formats need to expose the encoding's name or
label, they must expose it as "utf-8
".
To get an encoding from a string label, run these steps:
Remove any leading and trailing ASCII whitespace from label.
If label is an ASCII case-insensitive match for any of the labels listed in the table below, return the corresponding encoding, and failure otherwise.
This is a much simpler and more restrictive algorithm of mapping labels to encodings than section 1.4 of Unicode Technical Standard #22 prescribes, as that is found to be necessary to be compatible with deployed content.
| Name | Labels |
|---|---|
| The Encoding | |
| UTF-8 | "unicode-1-1-utf-8 "
|
"utf-8 "
| |
"utf8 "
| |
| Legacy single-byte encodings | |
| IBM866 | "866 "
|
"cp866 "
| |
"csibm866 "
| |
"ibm866 "
| |
| ISO-8859-2 | "csisolatin2 "
|
"iso-8859-2 "
| |
"iso-ir-101 "
| |
"iso8859-2 "
| |
"iso88592 "
| |
"iso_8859-2 "
| |
"iso_8859-2:1987 "
| |
"l2 "
| |
"latin2 "
| |
| ISO-8859-3 | "csisolatin3 "
|
"iso-8859-3 "
| |
"iso-ir-109 "
| |
"iso8859-3 "
| |
"iso88593 "
| |
"iso_8859-3 "
| |
"iso_8859-3:1988 "
| |
"l3 "
| |
"latin3 "
| |
| ISO-8859-4 | "csisolatin4 "
|
"iso-8859-4 "
| |
"iso-ir-110 "
| |
"iso8859-4 "
| |
"iso88594 "
| |
"iso_8859-4 "
| |
"iso_8859-4:1988 "
| |
"l4 "
| |
"latin4 "
| |
| ISO-8859-5 | "csisolatincyrillic "
|
"cyrillic "
| |
"iso-8859-5 "
| |
"iso-ir-144 "
| |
"iso8859-5 "
| |
"iso88595 "
| |
"iso_8859-5 "
| |
"iso_8859-5:1988 "
| |
| ISO-8859-6 | "arabic "
|
"asmo-708 "
| |
"csiso88596e "
| |
"csiso88596i "
| |
"csisolatinarabic "
| |
"ecma-114 "
| |
"iso-8859-6 "
| |
"iso-8859-6-e "
| |
"iso-8859-6-i "
| |
"iso-ir-127 "
| |
"iso8859-6 "
| |
"iso88596 "
| |
"iso_8859-6 "
| |
"iso_8859-6:1987 "
| |
| ISO-8859-7 | "csisolatingreek "
|
"ecma-118 "
| |
"elot_928 "
| |
"greek "
| |
"greek8 "
| |
"iso-8859-7 "
| |
"iso-ir-126 "
| |
"iso8859-7 "
| |
"iso88597 "
| |
"iso_8859-7 "
| |
"iso_8859-7:1987 "
| |
"sun_eu_greek "
| |
| ISO-8859-8 | "csiso88598e "
|
"csisolatinhebrew "
| |
"hebrew "
| |
"iso-8859-8 "
| |
"iso-8859-8-e "
| |
"iso-ir-138 "
| |
"iso8859-8 "
| |
"iso88598 "
| |
"iso_8859-8 "
| |
"iso_8859-8:1988 "
| |
"visual "
| |
| ISO-8859-8-I | "csiso88598i "
|
"iso-8859-8-i "
| |
"logical "
| |
| ISO-8859-10 | "csisolatin6 "
|
"iso-8859-10 "
| |
"iso-ir-157 "
| |
"iso8859-10 "
| |
"iso885910 "
| |
"l6 "
| |
"latin6 "
| |
| ISO-8859-13 | "iso-8859-13 "
|
"iso8859-13 "
| |
"iso885913 "
| |
| ISO-8859-14 | "iso-8859-14 "
|
"iso8859-14 "
| |
"iso885914 "
| |
| ISO-8859-15 | "csisolatin9 "
|
"iso-8859-15 "
| |
"iso8859-15 "
| |
"iso885915 "
| |
"iso_8859-15 "
| |
"l9 "
| |
| ISO-8859-16 | "iso-8859-16 "
|
| KOI8-R | "cskoi8r "
|
"koi "
| |
"koi8 "
| |
"koi8-r "
| |
"koi8_r "
| |
| KOI8-U | "koi8-ru "
|
"koi8-u "
| |
| macintosh | "csmacintosh "
|
"mac "
| |
"macintosh "
| |
"x-mac-roman "
| |
| windows-874 | "dos-874 "
|
"iso-8859-11 "
| |
"iso8859-11 "
| |
"iso885911 "
| |
"tis-620 "
| |
"windows-874 "
| |
| windows-1250 | "cp1250 "
|
"windows-1250 "
| |
"x-cp1250 "
| |
| windows-1251 | "cp1251 "
|
"windows-1251 "
| |
"x-cp1251 "
| |
| windows-1252 | "ansi_x3.4-1968 "
|
"ascii "
| |
"cp1252 "
| |
"cp819 "
| |
"csisolatin1 "
| |
"ibm819 "
| |
"iso-8859-1 "
| |
"iso-ir-100 "
| |
"iso8859-1 "
| |
"iso88591 "
| |
"iso_8859-1 "
| |
"iso_8859-1:1987 "
| |
"l1 "
| |
"latin1 "
| |
"us-ascii "
| |
"windows-1252 "
| |
"x-cp1252 "
| |
| windows-1253 | "cp1253 "
|
"windows-1253 "
| |
"x-cp1253 "
| |
| windows-1254 | "cp1254 "
|
"csisolatin5 "
| |
"iso-8859-9 "
| |
"iso-ir-148 "
| |
"iso8859-9 "
| |
"iso88599 "
| |
"iso_8859-9 "
| |
"iso_8859-9:1989 "
| |
"l5 "
| |
"latin5 "
| |
"windows-1254 "
| |
"x-cp1254 "
| |
| windows-1255 | "cp1255 "
|
"windows-1255 "
| |
"x-cp1255 "
| |
| windows-1256 | "cp1256 "
|
"windows-1256 "
| |
"x-cp1256 "
| |
| windows-1257 | "cp1257 "
|
"windows-1257 "
| |
"x-cp1257 "
| |
| windows-1258 | "cp1258 "
|
"windows-1258 "
| |
"x-cp1258 "
| |
| x-mac-cyrillic | "x-mac-cyrillic "
|
"x-mac-ukrainian "
| |
| Legacy multi-byte Chinese (simplified) encodings | |
| GBK | "chinese "
|
"csgb2312 "
| |
"csiso58gb231280 "
| |
"gb2312 "
| |
"gb_2312 "
| |
"gb_2312-80 "
| |
"gbk "
| |
"iso-ir-58 "
| |
"x-gbk "
| |
| gb18030 | "gb18030 "
|
| Legacy multi-byte Chinese (traditional) encodings | |
| Big5 | "big5 "
|
"big5-hkscs "
| |
"cn-big5 "
| |
"csbig5 "
| |
"x-x-big5 "
| |
| Legacy multi-byte Japanese encodings | |
| EUC-JP | "cseucpkdfmtjapanese "
|
"euc-jp "
| |
"x-euc-jp "
| |
| ISO-2022-JP | "csiso2022jp "
|
"iso-2022-jp "
| |
| Shift_JIS | "csshiftjis "
|
"ms932 "
| |
"ms_kanji "
| |
"shift-jis "
| |
"shift_jis "
| |
"sjis "
| |
"windows-31j "
| |
"x-sjis "
| |
| Legacy multi-byte Korean encodings | |
| EUC-KR | "cseuckr "
|
"csksc56011987 "
| |
"euc-kr "
| |
"iso-ir-149 "
| |
"korean "
| |
"ks_c_5601-1987 "
| |
"ks_c_5601-1989 "
| |
"ksc5601 "
| |
"ksc_5601 "
| |
"windows-949 "
| |
| Legacy miscellaneous encodings | |
| replacement | "csiso2022kr "
|
"hz-gb-2312 "
| |
"iso-2022-cn "
| |
"iso-2022-cn-ext "
| |
"iso-2022-kr "
| |
| UTF-16BE | "utf-16be "
|
| UTF-16LE | "utf-16 "
|
"utf-16le "
| |
| x-user-defined | "x-user-defined "
|
All encodings and their labels are also available as non-normative encodings.json resource.
To get an output encoding from an encoding encoding, run these steps:
If encoding is replacement, UTF-16BE, or UTF-16LE, return UTF-8.
Return encoding.
The get an output encoding algorithm is useful for URL parsing and HTML form submission, which both need exactly this.
Most legacy encodings make use of an index. An index is an ordered list of entries, each entry consisting of a pointer and a corresponding code point. Within an index pointers are unique and code points can be duplicated.
An efficient implementation likely has two indexes per encoding. One optimized for its decoder and one for its encoder.
To find the pointers and their corresponding code points in an index, let lines be the result of splitting the resource's contents on U+000A. Then remove each item in lines that is the empty string or starts with U+0023. Then the pointers and their corresponding code points are found by splitting each item in lines on U+0009. The first subitem is the pointer (as a decimal number) and the second is the corresponding code point (as a hexadecimal number). Other subitems are not relevant.
To signify changes an index includes an Identifier and a Date. If an Identifier has changed, so has the index.
The index code point for pointer in index is the code point corresponding to pointer in index, or null if pointer is not in index.
The index pointer for code point in index is the first pointer corresponding to code point in index, or null if code point is not in index.
These are the indexes defined by this specification, excluding index single-byte, which have their own table:
| Index | Notes | |
|---|---|---|
| index Big5 | index-big5.txt | This matches the Big5 standard in combination with the Hong Kong Supplementary Character Set and other common extensions. |
| index EUC-KR | index-euc-kr.txt | This matches the KS X 1001 standard and the Unified Hangul Code, more commonly known together as Windows Codepage 949. |
| index gb18030 | index-gb18030.txt | This matches the GB18030-2005 standard for code points encoded as two bytes, except for 0xA3 0xA0 which maps to U+3000 to be compatible with deployed content. |
| index gb18030 ranges | index-gb18030-ranges.txt | This index works different from all others. Listing all code points would result in over a million items whereas they can be represented neatly in 207 ranges combined with trivial limit checks. It therefore only superficially matches the GB18030-2005 standard for code points encoded as four bytes. See also index gb18030 ranges code point and index gb18030 ranges pointer below. |
| index jis0208 | index-jis0208.txt | This is the JIS X 0208 standard including formerly proprietary extensions from IBM and NEC. |
| index jis0212 | index-jis0212.txt | This is the JIS X 0212 standard. It is only used by the EUC-JP decoder due to lack of widespread support elsewhere. |
The index gb18030 ranges code point for pointer is the return value of these steps:
If pointer is greater than 39419 and less than 189000, or pointer is greater than 1237575, return null.
If pointer is 7457, return code point U+E7C7.
Let offset be the last pointer in index gb18030 ranges that is equal to or less than pointer and let code point offset be its corresponding code point.
Return a code point whose value is code point offset + pointer − offset.
The index gb18030 ranges pointer for code point is the return value of these steps:
If code point is U+E7C7, return pointer 7457.
Let offset be the last code point in index gb18030 ranges that is equal to or less than code point and let pointer offset be its corresponding pointer.
Return a pointer whose value is pointer offset + code point − offset.
The index Shift_JIS pointer for code point is the return value of these steps:
Let index be index jis0208 excluding all entries whose pointer is in the range 8272 to 8835, inclusive.
The index jis0208 contains duplicate code points so the exclusion of these entries causes later code points to be used.
Return the index pointer for code point in index.
The index Big5 pointer for code point is the return value of these steps:
Let index be index Big5 excluding all entries whose pointer is less than (0xA1 - 0x81) × 157.
Avoid returning Hong Kong Supplementary Character Set extensions literally.
If code point is U+2550, U+255E, U+2561, U+256A, U+5341, or U+5345, return the last pointer corresponding to code point in index.
There are other duplicate code points, but for those the first pointer is to be used.
Return the index pointer for code point in index.
All indexes are also available as non-normative indexes.json resource. (index gb18030 ranges has a slightly different format here, to be able to represent ranges.)
The algorithms decode, UTF-8 decode, UTF-8 decode without BOM, UTF-8 decode without BOM or fail, encode, and UTF-8 encode are intended for usage by other specifications. UTF-8 decode is to be used by new formats. The get an encoding algorithm can be used first to turn a label into an encoding.
To decode a byte stream stream using fallback encoding encoding, run these steps:
Let buffer be an empty byte sequence.
Let BOM seen flag be unset.
Read bytes from stream into buffer until either buffer contains three bytes or read returns end-of-stream.
For each of the rows in the table below, starting with the first one and going down, if the first bytes of buffer match all the bytes given in the first column, then set encoding to the encoding given in the cell in the second column of that row and set BOM seen flag.
| Byte order mark | Encoding |
|---|---|
| 0xEF 0xBB 0xBF | UTF-8 |
| 0xFE 0xFF | UTF-16BE |
| 0xFF 0xFE | UTF-16LE |
For compatibility with deployed content, the byte order mark (also known as BOM) is
more authoritative than anything else. In a context where HTTP is used this is in violation of the
semantics of the `Content-Type
` header.
If BOM seen flag is unset prepend buffer to stream.
Otherwise, if BOM seen flag is set, encoding is not UTF-8, and buffer contains three bytes, prepend the last byte of buffer to stream.
Let output be a code point stream.
Run encoding's decoder with stream and output.
Return output.
To UTF-8 decode a byte stream stream, run these steps:
Let buffer be an empty byte sequence.
Read three bytes from stream into buffer.
If buffer does not match 0xEF 0xBB 0xBF, prepend buffer to stream.
Let output be a code point stream.
Run UTF-8's decoder with stream and output.
Return output.
To UTF-8 decode without BOM a byte stream stream, run these steps:
Let output be a code point stream.
Run UTF-8's decoder with stream and output.
Return output.
To UTF-8 decode without BOM or fail a byte stream stream, run these steps:
Let output be a code point stream.
Let potentialError be the result of running
UTF-8's decoder with stream, output, and
"fatal
".
If potentialError is error, return failure.
Return output.
To encode a code point stream stream using encoding encoding, run these steps:
Assert: encoding is not replacement, UTF-16BE or UTF-16LE.
Let output be a byte stream.
Run encoding's
encoder with stream, output, and "html
".
Return output.
This is mostly a legacy hook for URLs and HTML forms. Layering UTF-8 encode on top is safe as it never triggers errors. URL HTML
To UTF-8 encode a code point stream stream, return the result of encoding stream using encoding UTF-8.
This section uses terminology from the DOM and Web IDL. Non-browser user agents are not required to support this API. DOM WEBIDL
The following example uses the TextEncoder
object to encode
an array of strings into an
ArrayBuffer
. The result is a
Uint8Array
containing the number
of strings (as a Uint32Array
),
followed by the length of the first string (as a
Uint32Array
), the
UTF-8 encoded string data, the length of the second string (as
a Uint32Array
), the string data,
and so on.
function encodeArrayOfStrings(strings) {
var encoder, encoded, len, bytes, view, offset;
encoder = new TextEncoder();
encoded = [];
len = Uint32Array.BYTES_PER_ELEMENT;
for (var i = 0; i < strings.length; i++) {
len += Uint32Array.BYTES_PER_ELEMENT;
encoded[i] = encoder.encode(strings[i]);
len += encoded[i].byteLength;
}
bytes = new Uint8Array(len);
view = new DataView(bytes.buffer);
offset = 0;
view.setUint32(offset, strings.length);
offset += Uint32Array.BYTES_PER_ELEMENT;
for (var i = 0; i < encoded.length; i += 1) {
len = encoded[i].byteLength;
view.setUint32(offset, len);
offset += Uint32Array.BYTES_PER_ELEMENT;
bytes.set(encoded[i], offset);
offset += len;
}
return bytes.buffer;
}
The following example decodes an ArrayBuffer
containing data encoded in the
format produced by the previous example, or an equivalent algorithm for encodings other than
UTF-8, back into an array of strings.
function decodeArrayOfStrings(buffer, encoding) {
var decoder, view, offset, num_strings, strings, len;
decoder = new TextDecoder(encoding);
view = new DataView(buffer);
offset = 0;
strings = [];
num_strings = view.getUint32(offset);
offset += Uint32Array.BYTES_PER_ELEMENT;
for (var i = 0; i < num_strings; i++) {
len = view.getUint32(offset);
offset += Uint32Array.BYTES_PER_ELEMENT;
strings[i] = decoder.decode(
new DataView(view.buffer, offset, len));
offset += len;
}
return strings;
}
TextDecoder
dictionary TextDecoderOptions { boolean fatal = false; boolean ignoreBOM = false; }; dictionary TextDecodeOptions { boolean stream = false; }; [Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options), Exposed=(Window,Worker)] interface TextDecoder { readonly attribute DOMString encoding; readonly attribute boolean fatal; readonly attribute boolean ignoreBOM; USVString decode(optional BufferSource input, optional TextDecodeOptions options); };
A TextDecoder
object has an associated encoding, decoder,
stream, ignore BOM flag (initially unset),
BOM seen flag (initially unset),
error mode (initially "replacement
"), and
do not flush flag (initially unset).
A TextDecoder
object also has an associated
serialize stream algorithm, that given a
stream stream, runs these steps:
Let output be the empty string.
While true:
Let token be the result of reading from stream.
If encoding is UTF-8, UTF-16BE, or UTF-16LE, and ignore BOM flag and BOM seen flag are unset, run these subsubsteps:
If token is U+FEFF, set BOM seen flag.
Otherwise, if token is not end-of-stream, set BOM seen flag and append token to output.
Otherwise, return output.
Otherwise, if token is not end-of-stream, append token to output.
Otherwise, return output.
This algorithm is intentionally different with respect to BOM handling from the decode algorithm used by the rest of the platform to give API users more control.
decoder = new TextDecoder([label = "utf-8" [, options]])
Returns a new TextDecoder
object.
If label is either not a label or is a
label for replacement,
throws a
RangeError
.
decoder . encoding
Returns encoding's name, lowercased.
decoder . fatal
Returns true if error mode is "fatal
", and false otherwise.
decoder . ignoreBOM
Returns true if ignore BOM flag is set, and false otherwise.
decoder . decode([input [, options]])
Returns the result of running encoding's decoder. The method can be invoked
zero or more times with options's stream
set to true, and then once
without options's stream
(or set to false), to process a fragmented
stream. If the invocation without options's stream
(or set to false)
has no input, it's clearest to omit both arguments.
var string = "", decoder = TextDecoder(encoding), buffer; while(buffer = next_chunk()) { string += decoder.decode(buffer, {stream:true}); } string += decoder.decode(); // end-of-stream
If the error mode is "fatal
" and encoding's decoder
returns error, throws a
TypeError
.
The
TextDecoder(label, options)
constructor, when invoked, must run these steps:
Let encoding be the result of getting an encoding from label.
If encoding is failure or replacement,
throw a RangeError
.
Let dec be a new TextDecoder
object.
Set dec's encoding to encoding.
If options's fatal
member is
true, set dec's error mode to "fatal
".
If options's ignoreBOM
member is
true, set dec's ignore BOM flag.
Return dec.
The encoding
attribute's getter must
return encoding's name in ASCII lowercase.
The fatal
attribute's getter must
return true if error mode is "fatal
", and false otherwise.
The ignoreBOM
attribute's
getter must return true if ignore BOM flag is set, and false otherwise.
The
decode(input, options)
method, when invoked, must run these steps:
If the do not flush flag is unset, set decoder to a new encoding's decoder, set stream to a new stream, and unset the BOM seen flag.
If options's stream
is true, set the
do not flush flag, and unset the do not flush flag otherwise.
If input is given, push a copy of input to stream.
Let output be a new stream.
While true:
Let token be the result of reading from stream.
If token is end-of-stream and the do not flush flag is set, return output, serialized.
The way streaming works is to not handle end-of-stream here when the do not flush flag is set and to not unset that flag. That way in a subsequent invocation decoder is not set anew in the first step of the algorithm and its state is preserved.
Otherwise, run these subsubsteps:
Let result be the result of processing token for decoder, stream, output, and error mode.
If result is finished, return output, serialized.
Otherwise, if result is error,
throw a TypeError
.
Otherwise, do nothing.
TextEncoder
[Constructor, Exposed=(Window,Worker)] interface TextEncoder { readonly attribute DOMString encoding; [NewObject] Uint8Array encode(optional USVString input = ""); };
A TextEncoder
object has an associated encoder.
A TextEncoder
object offers no label argument as
it only supports UTF-8. It also offers no stream
option as no
encoder requires buffering of scalar values.
encoder = new TextEncoder()
Returns a new TextEncoder
object.
encoder . encoding
Returns "utf-8
".
encoder . encode([input = ""])
Returns the result of running UTF-8's encoder.
The TextEncoder()
constructor, when invoked, must
run these steps:
Let enc be a new TextEncoder
object.
Set enc's encoder to UTF-8's encoder.
Return enc.
The encoding
attribute's getter must
return "utf-8
".
The
encode(input)
method, when invoked, must run these steps:
Convert input to a stream.
Let output be a new stream.
While true, run these substeps:
Let token be the result of reading from input.
Let result be the result of processing token for encoder, input, output.
If result is finished, convert output into a
byte sequence, and then return a Uint8Array
object wrapping an
ArrayBuffer
containing output.
These encodings cannot return error.
UTF-8's decoder's has an associated UTF-8 code point, UTF-8 bytes seen, and UTF-8 bytes needed (all initially 0), a UTF-8 lower boundary (initially 0x80), and a UTF-8 upper boundary (initially 0xBF).
UTF-8's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream and UTF-8 bytes needed is not 0, set UTF-8 bytes needed to 0 and return error.
If byte is end-of-stream, return finished.
If UTF-8 bytes needed is 0, based on byte:
Return a code point whose value is byte.
Set UTF-8 bytes needed to 1.
Set UTF-8 code point to byte & 0x1F.
The five least significant bits of byte.
If byte is 0xE0, set UTF-8 lower boundary to 0xA0.
If byte is 0xED, set UTF-8 upper boundary to 0x9F.
Set UTF-8 bytes needed to 2.
Set UTF-8 code point to byte & 0xF.
The four least significant bits of byte.
If byte is 0xF0, set UTF-8 lower boundary to 0x90.
If byte is 0xF4, set UTF-8 upper boundary to 0x8F.
Set UTF-8 bytes needed to 3.
Set UTF-8 code point to byte & 0x7.
The three least significant bits of byte.
Return error.
Return continue.
If byte is not in the range UTF-8 lower boundary to UTF-8 upper boundary, inclusive, run these substeps:
Set UTF-8 code point, UTF-8 bytes needed, and UTF-8 bytes seen to 0, set UTF-8 lower boundary to 0x80, and set UTF-8 upper boundary to 0xBF.
Prepend byte to stream.
Return error.
Set UTF-8 lower boundary to 0x80 and UTF-8 upper boundary to 0xBF.
Set UTF-8 code point to (UTF-8 code point << 6) | (byte & 0x3F)
Shift the existing bits of UTF-8 code point left by six places and set the newly-vacated six least significant bits to the six least significant bits of byte.
Increase UTF-8 bytes seen by one.
If UTF-8 bytes seen is not equal to UTF-8 bytes needed, return continue.
Let code point be UTF-8 code point.
Set UTF-8 code point, UTF-8 bytes needed, and UTF-8 bytes seen to 0.
Return a code point whose value is code point.
The constraints in the UTF-8 decoder above match “Best Practices for Using U+FFFD” from the Unicode standard. No other behavior is permitted per the Encoding Standard (other algorithms that achieve the same result are obviously fine, even encouraged). UNICODE
UTF-8's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point, return a byte whose value is code point.
Set count and offset based on the range code point is in:
Let bytes be a byte sequence whose first byte is (code point >> (6 × count)) + offset.
Run these substeps while count is greater than 0:
Set temp to code point >> (6 × (count − 1)).
Append to bytes 0x80 | (temp & 0x3F).
Decrease count by one.
Return bytes bytes, in order.
This algorithm has identical results to the one described in the Unicode standard. It is included here for completeness. UNICODE
An encoding where each byte is either a single code point or nothing, is a single-byte encoding. Single-byte encodings share the decoder and encoder. Index single-byte, as referenced by the single-byte decoder and single-byte encoder, is defined by the following table, and depends on the single-byte encoding in use. All but two single-byte encodings have a unique index.
| Name | Index |
|---|---|
| IBM866 | index-ibm866.txt |
| ISO-8859-2 | index-iso-8859-2.txt |
| ISO-8859-3 | index-iso-8859-3.txt |
| ISO-8859-4 | index-iso-8859-4.txt |
| ISO-8859-5 | index-iso-8859-5.txt |
| ISO-8859-6 | index-iso-8859-6.txt |
| ISO-8859-7 | index-iso-8859-7.txt |
| ISO-8859-8 | index-iso-8859-8.txt |
| ISO-8859-8-I | |
| ISO-8859-10 | index-iso-8859-10.txt |
| ISO-8859-13 | index-iso-8859-13.txt |
| ISO-8859-14 | index-iso-8859-14.txt |
| ISO-8859-15 | index-iso-8859-15.txt |
| ISO-8859-16 | index-iso-8859-16.txt |
| KOI8-R | index-koi8-r.txt |
| KOI8-U | index-koi8-u.txt |
| macintosh | index-macintosh.txt |
| windows-874 | index-windows-874.txt |
| windows-1250 | index-windows-1250.txt |
| windows-1251 | index-windows-1251.txt |
| windows-1252 | index-windows-1252.txt |
| windows-1253 | index-windows-1253.txt |
| windows-1254 | index-windows-1254.txt |
| windows-1255 | index-windows-1255.txt |
| windows-1256 | index-windows-1256.txt |
| windows-1257 | index-windows-1257.txt |
| windows-1258 | index-windows-1258.txt |
| x-mac-cyrillic | index-x-mac-cyrillic.txt |
ISO-8859-8 and ISO-8859-8-I are distinct encoding names, because ISO-8859-8 has influence on the layout direction. And although historically this might have been the case for ISO-8859-6 and "iso-8859-6-i" as well, that is no longer true.
Single-byte encodings's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream, return finished.
If byte is an ASCII byte, return a code point whose value is byte.
Let code point be the index code point for byte − 0x80 in index single-byte.
If code point is null, return error.
Return a code point whose value is code point.
Single-byte encodings's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point, return a byte whose value is code point.
Let pointer be the index pointer for code point in index single-byte.
If pointer is null, return error with code point.
Return a byte whose value is pointer + 0x80.
GBK's decoder is gb18030's decoder.
GBK's encoder is gb18030's encoder with its GBK flag set.
Not fully aliasing GBK with gb18030 is a conservative move to decrease the chances of breaking legacy servers and other consumers of content generated with GBK's encoder.
gb18030's decoder has an associated gb18030 first, gb18030 second, and gb18030 third (all initially 0x00).
gb18030's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream and gb18030 first, gb18030 second, and gb18030 third are 0x00, return finished.
If byte is end-of-stream, and gb18030 first, gb18030 second, or gb18030 third is not 0x00, set gb18030 first, gb18030 second, and gb18030 third to 0x00, and return error.
If gb18030 third is not 0x00, run these substeps:
Let code point be null.
If byte is in the range 0x30 to 0x39, inclusive, set code point to the index gb18030 ranges code point for ((gb18030 first − 0x81) × (10 × 126 × 10)) + ((gb18030 second − 0x30) × (10 × 126)) + ((gb18030 third − 0x81) × 10) + byte − 0x30.
Let buffer be a byte sequence consisting of gb18030 second, gb18030 third, and byte, in order.
Set gb18030 first, gb18030 second, and gb18030 third to 0x00.
If code point is null, prepend buffer to stream and return error.
Return a code point whose value is code point.
If gb18030 second is not 0x00, run these substeps:
If byte is in the range 0x81 to 0xFE, inclusive, set gb18030 third to byte and return continue.
Prepend gb18030 second followed by byte to stream, set gb18030 first and gb18030 second to 0x00, and return error.
If gb18030 first is not 0x00, run these substeps:
If byte is in the range 0x30 to 0x39, inclusive, set gb18030 second to byte and return continue.
Let lead be gb18030 first, let pointer be null, and set gb18030 first to 0x00.
Let offset be 0x40 if byte is less than 0x7F and 0x41 otherwise.
If byte is in the range 0x40 to 0x7E, inclusive, or 0x80 to 0xFE, inclusive, set pointer to (lead − 0x81) × 190 + (byte − offset).
Let code point be null if pointer is null and the index code point for pointer in index gb18030 otherwise.
If code point is null and byte is an ASCII byte, prepend byte to stream.
If code point is null, return error.
Return a code point whose value is code point.
If byte is an ASCII byte, return a code point whose value is byte.
If byte is 0x80, return code point U+20AC.
If byte is in the range 0x81 to 0xFE, inclusive, set gb18030 first to byte and return continue.
Return error.
gb18030's encoder has an associated GBK flag (initially unset).
gb18030's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point, return a byte whose value is code point.
If code point is U+E5E5, return error with code point.
Index gb18030 maps 0xA3 0xA0 to U+3000 rather than U+E5E5 for compatibility with deployed content. Therefore it cannot roundtrip.
If the GBK flag is set and code point is U+20AC, return byte 0x80.
Let pointer be the index pointer for code point in index gb18030.
If pointer is not null, run these substeps:
Let lead be floor(pointer / 190) + 0x81.
Let trail be pointer % 190.
Let offset be 0x40 if trail is less than 0x3F and 0x41 otherwise.
Return two bytes whose values are lead and trail + offset.
If GBK flag is set, return error with code point.
Set pointer to the index gb18030 ranges pointer for code point.
Let byte1 be floor(pointer / (10 × 126 × 10)).
Set pointer to pointer % (10 × 126 × 10).
Let byte2 be floor(pointer / (10 × 126)).
Set pointer to pointer % (10 × 126).
Let byte3 be floor(pointer / 10).
Let byte4 be pointer % 10.
Return four bytes whose values are byte1 + 0x81, byte2 + 0x30, byte3 + 0x81, byte4 + 0x30.
Big5's decoder has an associated Big5 lead (initially 0x00). Big5's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream and Big5 lead is not 0x00, set Big5 lead to 0x00 and return error.
If byte is end-of-stream and Big5 lead is 0x00, return finished.
If Big5 lead is not 0x00, let lead be Big5 lead, let pointer be null, set Big5 lead to 0x00, and then run these substeps:
Let offset be 0x40 if byte is less than 0x7F and 0x62 otherwise.
If byte is in the range 0x40 to 0x7E, inclusive, or 0xA1 to 0xFE, inclusive, set pointer to (lead − 0x81) × 157 + (byte − offset).
If there is a row in the table below whose first column is pointer, return the two code points listed in its second column (the third column is irrelevant):
| Pointer | Code points | Notes |
|---|---|---|
| 1133 | U+00CA U+0304 | Ê̄ (LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND MACRON) |
| 1135 | U+00CA U+030C | Ê̌ (LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND CARON) |
| 1164 | U+00EA U+0304 | ê̄ (LATIN SMALL LETTER E WITH CIRCUMFLEX AND MACRON) |
| 1166 | U+00EA U+030C | ê̌ (LATIN SMALL LETTER E WITH CIRCUMFLEX AND CARON) |
Since indexes are limited to single code points this table is used for these pointers.
Let code point be null if pointer is null and the index code point for pointer in index Big5 otherwise.
If code point is null and byte is an ASCII byte, prepend byte to stream.
If code point is null, return error.
Return a code point whose value is code point.
If byte is an ASCII byte, return a code point whose value is byte.
If byte is in the range 0x81 to 0xFE, inclusive, set Big5 lead to byte and return continue.
Return error.
Big5's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point, return a byte whose value is code point.
Let pointer be the index Big5 pointer for code point.
If pointer is null, return error with code point.
Let lead be floor(pointer / 157) + 0x81.
Let trail be pointer % 157.
Let offset be 0x40 if trail is less than 0x3F and 0x62 otherwise.
Return two bytes whose values are lead and trail + offset.
EUC-JP's decoder has an associated EUC-JP jis0212 flag (initially unset) and EUC-JP lead (initially 0x00).
EUC-JP's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream and EUC-JP lead is not 0x00, set EUC-JP lead to 0x00, and return error.
If byte is end-of-stream and EUC-JP lead is 0x00, return finished.
If EUC-JP lead is 0x8E and byte is in the range 0xA1 to 0xDF, inclusive, set EUC-JP lead to 0x00 and return a code point whose value is 0xFF61 − 0xA1 + byte.
If EUC-JP lead is 0x8F and byte is in the range 0xA1 to 0xFE, inclusive, set the EUC-JP jis0212 flag, set EUC-JP lead to byte, and return continue.
If EUC-JP lead is not 0x00, let lead be EUC-JP lead, set EUC-JP lead to 0x00, and run these substeps:
Let code point be null.
If lead and byte are both in the range 0xA1 to 0xFE, inclusive, set code point to the index code point for (lead − 0xA1) × 94 + byte − 0xA1 in index jis0208 if the EUC-JP jis0212 flag is unset and in index jis0212 otherwise.
Unset the EUC-JP jis0212 flag.
If byte is not in the range 0xA1 to 0xFE, inclusive, prepend byte to stream.
If code point is null, return error.
Return a code point whose value is code point.
If byte is an ASCII byte, return a code point whose value is byte.
If byte is 0x8E, 0x8F, or in the range 0xA1 to 0xFE, inclusive, set EUC-JP lead to byte and return continue.
Return error.
EUC-JP's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point, return a byte whose value is code point.
If code point is U+00A5, return byte 0x5C.
If code point is U+203E, return byte 0x7E.
If code point is in the range U+FF61 to U+FF9F, inclusive, return two bytes whose values are 0x8E and code point − 0xFF61 + 0xA1.
If code point is U+2212, set it to U+FF0D.
Let pointer be the index pointer for code point in index jis0208.
If pointer is null, return error with code point.
Let lead be floor(pointer / 94) + 0xA1.
Let trail be pointer % 94 + 0xA1.
Return two bytes whose values are lead and trail.
ISO-2022-JP's decoder has an associated ISO-2022-JP decoder state (initially ASCII), ISO-2022-JP decoder output state (initially ASCII), ISO-2022-JP lead (initially 0x00), and ISO-2022-JP output flag (initially unset).
ISO-2022-JP's decoder's handler, given a stream and byte, runs these steps, switching on ISO-2022-JP decoder state:
Based on byte:
Set ISO-2022-JP decoder state to escape start and return continue.
Unset the ISO-2022-JP output flag and return a code point whose value is byte.
Return finished.
Unset the ISO-2022-JP output flag and return error.
Based on byte:
Set ISO-2022-JP decoder state to escape start and return continue.
Unset the ISO-2022-JP output flag and return code point U+00A5.
Unset the ISO-2022-JP output flag and return code point U+203E.
Unset the ISO-2022-JP output flag and return a code point whose value is byte.
Return finished.
Unset the ISO-2022-JP output flag and return error.
Based on byte:
Set ISO-2022-JP decoder state to escape start and return continue.
Unset the ISO-2022-JP output flag and return a code point whose value is 0xFF61 − 0x21 + byte.
Return finished.
Unset the ISO-2022-JP output flag and return error.
Based on byte:
Set ISO-2022-JP decoder state to escape start and return continue.
Unset the ISO-2022-JP output flag, set ISO-2022-JP lead to byte, ISO-2022-JP decoder state to trail byte, and return continue.
Return finished.
Unset the ISO-2022-JP output flag and return error.
Based on byte:
Set ISO-2022-JP decoder state to escape start and return error.
Set the ISO-2022-JP decoder state to lead byte.
Let pointer be (ISO-2022-JP lead − 0x21) × 94 + byte − 0x21.
Let code point be the index code point for pointer in index jis0208.
If code point is null, return error.
Return a code point whose value is code point.
Set the ISO-2022-JP decoder state to lead byte, prepend byte to stream, and return error.
Set ISO-2022-JP decoder state to lead byte and return error.
If byte is either 0x24 or 0x28, set ISO-2022-JP lead to byte, ISO-2022-JP decoder state to escape, and return continue.
Prepend byte to stream.
Unset the ISO-2022-JP output flag, set ISO-2022-JP decoder state to ISO-2022-JP decoder output state, and return error.
Let lead be ISO-2022-JP lead and set ISO-2022-JP lead to 0x00.
Let state be null.
If lead is 0x28 and byte is 0x42, set state to ASCII.
If lead is 0x28 and byte is 0x4A, set state to Roman.
If lead is 0x28 and byte is 0x49, set state to Katakana.
If lead is 0x24 and byte is either 0x40 or 0x42, set state to lead byte.
If state is non-null, run these substeps:
Set ISO-2022-JP decoder state and ISO-2022-JP decoder output state to state.
Let output flag be the ISO-2022-JP output flag.
Set the ISO-2022-JP output flag.
Return continue, if output flag is unset, and error otherwise.
Prepend lead and byte to stream.
Unset the ISO-2022-JP output flag, set ISO-2022-JP decoder state to ISO-2022-JP decoder output state and return error.
ISO-2022-JP's encoder has an associated ISO-2022-JP encoder state which is ASCII, Roman, or jis0208 (initially ASCII).
ISO-2022-JP's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream and ISO-2022-JP encoder state is not ASCII, prepend code point to stream, set ISO-2022-JP encoder state to ASCII, and return three bytes 0x1B 0x28 0x42.
If code point is end-of-stream and ISO-2022-JP encoder state is ASCII, return finished.
If ISO-2022-JP encoder state is ASCII or Roman, and code point is U+000E, U+000F, or U+001B, return error with U+FFFD.
This returns U+FFFD rather than the code point to prevent attacks.
If ISO-2022-JP encoder state is ASCII and code point is an ASCII code point, return a byte whose value is code point.
If ISO-2022-JP encoder state is Roman and code point is an ASCII code point, excluding U+005C and U+007E, or is U+00A5 or U+203E, run these substeps:
If code point is an ASCII code point, return a byte whose value is code point.
If code point is U+00A5, return byte 0x5C.
If code point is U+203E, return byte 0x7E.
If code point is an ASCII code point, and ISO-2022-JP encoder state is not ASCII, prepend code point to stream, set ISO-2022-JP encoder state to ASCII, and return three bytes 0x1B 0x28 0x42.
If code point is either U+00A5 or U+203E, and ISO-2022-JP encoder state is not Roman, prepend code point to stream, set ISO-2022-JP encoder state to Roman, and return three bytes 0x1B 0x28 0x4A.
If code point is U+2212, set it to U+FF0D.
Let pointer be the index pointer for code point in index jis0208.
If pointer is null, return error with code point.
If ISO-2022-JP encoder state is not jis0208, prepend code point to stream, set ISO-2022-JP encoder state to jis0208, and return three bytes 0x1B 0x24 0x42.
Let lead be floor(pointer / 94) + 0x21.
Let trail be pointer % 94 + 0x21.
Return two bytes whose values are lead and trail.
Shift_JIS's decoder has an associated Shift_JIS lead (initially 0x00).
Shift_JIS's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream and Shift_JIS lead is not 0x00, set Shift_JIS lead to 0x00 and return error.
If byte is end-of-stream and Shift_JIS lead is 0x00, return finished.
If Shift_JIS lead is not 0x00, let lead be Shift_JIS lead, let pointer be null, set Shift_JIS lead to 0x00, and then run these substeps:
Let offset be 0x40, if byte is less than 0x7F, and 0x41 otherwise.
Let lead offset be 0x81, if lead is less than 0xA0, and 0xC1 otherwise.
If byte is in the range 0x40 to 0x7E, inclusive, or 0x80 to 0xFC, inclusive, set pointer to (lead − lead offset) × 188 + byte − offset.
If pointer is in the range 8836 to 10715, inclusive, return a code point whose value is 0xE000 − 8836 + pointer.
This is interoperable legacy from Windows known as EUDC.
Let code point be null, if pointer is null, and the index code point for pointer in index jis0208 otherwise.
If code point is null and byte is an ASCII byte, prepend byte to stream.
If code point is null, return error.
Return a code point whose value is code point.
If byte is an ASCII byte or 0x80, return a code point whose value is byte.
If byte is in the range 0xA1 to 0xDF, inclusive, return a code point whose value is 0xFF61 − 0xA1 + byte.
If byte is in the range 0x81 to 0x9F, inclusive, or 0xE0 to 0xFC, inclusive, set Shift_JIS lead to byte and return continue.
Return error.
Shift_JIS's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point or U+0080, return a byte whose value is code point.
If code point is U+00A5, return byte 0x5C.
If code point is U+203E, return byte 0x7E.
If code point is in the range U+FF61 to U+FF9F, inclusive, return a byte whose value is code point − 0xFF61 + 0xA1.
If code point is U+2212, set it to U+FF0D.
Let pointer be the index Shift_JIS pointer for code point.
If pointer is null, return error with code point.
Let lead be floor(pointer / 188).
Let lead offset be 0x81, if lead is less than 0x1F, and 0xC1 otherwise.
Let trail be pointer % 188.
Let offset be 0x40, if trail is less than 0x3F, and 0x41 otherwise.
Return two bytes whose values are lead + lead offset and trail + offset.
EUC-KR's decoder has an associated EUC-KR lead (initially 0x00).
EUC-KR's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream and EUC-KR lead is not 0x00, set EUC-KR lead to 0x00 and return error.
If byte is end-of-stream and EUC-KR lead is 0x00, return finished.
If EUC-KR lead is not 0x00, let lead be EUC-KR lead, let pointer be null, set EUC-KR lead to 0x00, and then run these substeps:
If byte is in the range 0x41 to 0xFE, inclusive, set pointer to (lead − 0x81) × 190 + (byte − 0x41).
Let code point be null, if pointer is null, and the index code point for pointer in index EUC-KR otherwise.
If code point is null and byte is an ASCII byte, prepend byte to stream.
If code point is null, return error.
Return a code point whose value is code point.
If byte is an ASCII byte, return a code point whose value is byte.
If byte is in the range 0x81 to 0xFE, inclusive, set EUC-KR lead to byte and return continue.
Return error.
EUC-KR's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point, return a byte whose value is code point.
Let pointer be the index pointer for code point in index EUC-KR.
If pointer is null, return error with code point.
Let lead be floor(pointer / 190) + 0x81.
Let trail be pointer % 190 + 0x41.
Return two bytes whose values are lead and trail.
The replacement encoding exists to prevent certain attacks that abuse a mismatch between encodings supported on the server and the client.
replacement's decoder has an associated replacement error returned flag (initially unset).
replacement's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream, return finished.
If replacement error returned flag is unset, set the replacement error returned flag and return error.
Return finished.
A byte order mark has priority over a label as it has been found to be more accurate in deployed content. Therefore it is not part of the shared UTF-16 decoder algorithm but rather the decode algorithm.
shared UTF-16 decoder has an associated UTF-16 lead byte and UTF-16 lead surrogate (both initially null), and UTF-16BE decoder flag (initially unset).
shared UTF-16 decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream and either UTF-16 lead byte or UTF-16 lead surrogate is not null, set UTF-16 lead byte and UTF-16 lead surrogate to null, and return error.
If byte is end-of-stream and UTF-16 lead byte and UTF-16 lead surrogate are null, return finished.
If UTF-16 lead byte is null, set UTF-16 lead byte to byte and return continue.
Let code unit be the result of:
(UTF-16 lead byte << 8) + byte.
(byte << 8) + UTF-16 lead byte.
Then set UTF-16 lead byte to null.
If UTF-16 lead surrogate is not null, let lead surrogate be UTF-16 lead surrogate, set UTF-16 lead surrogate to null, and then run these substeps:
If code unit is in the range U+DC00 to U+DFFF, inclusive, return a code point whose value is 0x10000 + ((lead surrogate − 0xD800) << 10) + (code unit − 0xDC00).
Let bytes be the return value of running these subsubsteps:
Let byte1 be code unit >> 8.
Let byte2 be code unit & 0x00FF.
Then return the bytes in order, switching on UTF-16BE decoder flag:
byte1, then byte2.
byte2, then byte1.
Prepend the bytes to stream and return error.
If code unit is in the range U+D800 to U+DBFF, inclusive, set UTF-16 lead surrogate to code unit and return continue.
If code unit is in the range U+DC00 to U+DFFF, inclusive, return error.
Return code point code unit.
UTF-16BE's decoder is shared UTF-16 decoder with its UTF-16BE decoder flag set.
Both "utf-16
" and
"utf-16le
" are labels for
UTF-16LE to deal with deployed content.
UTF-16LE's decoder is shared UTF-16 decoder.
While technically this is a single-byte encoding, it is defined separately as it can be implemented algorithmically.
x-user-defined's decoder's handler, given a stream and byte, runs these steps:
If byte is end-of-stream, return finished.
If byte is an ASCII byte, return a code point whose value is byte.
Return a code point whose value is 0xF780 + byte − 0x80.
x-user-defined's encoder's handler, given a stream and code point, runs these steps:
If code point is end-of-stream, return finished.
If code point is an ASCII code point, return a byte whose value is code point.
If code point is in the range U+F780 to U+F7FF, inclusive, return a byte whose value is code point − 0xF780 + 0x80.
Return error with code point.
Browsers are encouraged to not enable overriding the encoding of a resource. If such a feature is nonetheless present, browsers should not offer either UTF-16BE or UTF-16LE as option due to aforementioned security issues. Browsers also should disable this feature if the resource was decoded using either UTF-16BE or UTF-16LE.
There have been a lot of people that have helped make encodings more interoperable over the years and thereby furthered the goals of this standard. Likewise many people have helped making this standard what it is today.
With that, many thanks to Adam Rice, Alan Chaney, Alexander Shtuchkin, Allen Wirfs-Brock, Aneesh Agrawal, Arkadiusz Michalski, Asmus Freytag, Ben Noordhuis, Boris Zbarsky, Bruno Haible, Cameron McCormack, Charles McCathieNeville, David Carlisle, Domenic Denicola, Dominique Hazaël-Massieux, Doug Ewell, Erik van der Poel, 譚永鋒 (Frank Yung-Fong Tang), Geoffrey Sneddon, Glenn Maynard, Gordon P. Hemsley, Henri Sivonen, Ian Hickson, James Graham, Jeffrey Yasskin, John Tamplin, Joshua Bell, 村井純 (Jun Murai), 신정식 (Jungshik Shin), Jxck, 강 성훈 (Kang Seonghoon), 川幡太一 (Kawabata Taichi), Ken Lunde, Ken Whistler, Kenneth Russell, 田村健人 (Kent Tamura), Leif Halvard Silli, Makoto Kato, Mark Callow, Mark Crispin, Mark Davis, Martin Dürst, Masatoshi Kimura, Ms2ger, Nigel Megitt, Nigel Tao, Norbert Lindenberg, Øistein E. Andersen, Peter Krefting, Philip Jägenstedt, Philip Taylor, Richard Ishida, Robbert Broersma, Robert Mustacchi, Ryan Dahl, Shawn Steele, Simon Montagu, Simon Pieters, Simon Sapin, 寺田健 (Takeshi Terada), Vyacheslav Matva, and 成瀬ゆい (Yui Naruse) for being awesome.
This standard is written by Anne van Kesteren (Mozilla, annevk@annevk.nl). The API chapter was initially written by Joshua Bell (Google).
Per CC0, to the extent possible under law, the editors have waived all copyright and related or neighboring rights to this work.


This is a personal project I took on, where I choose a system I was innately familiar with, conducted a survey, performed an audit and performed a competitive analysis of other similar systems. In conclusion, based on my research, created a whole new flow.
MARTA stands for Metropolitan Atlanta Rapid Transit Authority. MARTA is Atlanta’s main transit system.
If you are regular MARTA user, you would purchase a breeze card and reload your breeze card with a MARTA kiosk. The breeze card grants access to the ...
Because of all the access the MARTA card has - the kiosk has a lot of rules and flows.
The MARTA kiosk flow has remained unchanged for years. In Atlanta, this system touches millions of workers' ability to get to their jobs and homes. Improving the flow of this system can decrease queue time, and can prevent users from interacting with other modes of transportation. If so, the government will loose points of sale and carbon will be added to the environment due to an increase in car usage. If we can improve this flow, we can bring more users to the machine, more users to the MARTA, less cars on the road and more government revenue.
Considering the use of the machine, we know users are most likely in a rush to get to their location. Keeping that in mind when decreasing the flow, and prioritizing those who use it most can mitigate that pain of using the machine.
While designing this system I kept in mind two of my biggest limitations, the physical buttons and the various access options the breeze card gave.
Due to the fact that there are so many opportunities for your breeze card, the kiosk can be overwhelming. Not only are there too many options, but there is no priority for commonly used user actions , such as those who own a breeze card.
Because the physical buttons were placed evenly on the screen and all equidistant from one other, I had no free choice over where to place the options.
I created a short 10 question survey about users’ experience with the MARTA system. The questions were mulitple choice and a couple free anwser. I posted the survey on my facebook wall to get results from my communtity. From that survey I got 34 response and most of the responses were 18-35 years old.
In short, the results are
These results tell me what users 18-35 years old thought about the MARTA system. I know from this data 93% users use trains, that means I should prioritize the trains on this platform, as oppose to buses. I also know most users use the machine to reload their card, as opposing to buying a ticket or buying a card, so prioritizing those with a card. I also see from this data that most users buy a single or round trip as oppose to mass loading money on their card, from that I am making sure I provide those options.
Looking at these survey results, I considered that most of my facebook friends were from a different socio-economic background than those who normally use MARTA. I researched what differences MARTA put into their flow to account for that. MARTA has discounted prices on bulk money refills on the card so providing an easy option to customize price was included in this. I also discovered that many people switch between trains, so loading a lot of money on their card is the easiest way to pay for that. Keeping that in mind I included a "Same-Day Transfer" option, to reduce the flow for those who do that.
Screens - this indicates how many screens the user had to interact with to purchase a round trip.

A MARTA rider, in order to purchase 2 trips ( otherwise known as a round trip and a basic purchase from the kiosk) has to go through 13 screens, and interact with the machine 11 times.
A MARTA rider, in order to purchase a standard trip in my new redesign has to go through 9 screens, and interact with the machine 7 times.
The potential Impact of this flow could decrease service time per customer, decrease queue time overall and increase usability. All three of these aspects will lead to a happier user.


Use a javax.swing.border.TitledBorder to draw a group box (Cocoa NSBox) using the Quaqua Look and Feel. Group boxes have a rounded border and a content area that is slightly darker than the surrounding area.
You can create titled borders with a title text or without one:
|
|
Please note that a TitledBorder does not work properly with a javax.swing.Box component. This is because a Box component does not have an UI delegate at all. Thus its appearance is not fully in control by the Look and Feel in use.
As a workaround, you can use a JPanel with BoxLayout.


About Me
My name is Vaishnavi Shah, I'm 21 years old creative web designer based in India, specializing in Website Development. I build clean, appealing, responsive and functional website which comply with the latest web devloping standards. I am currently looking for a job in web designing or web developeing. I am persuing bachelor degree from KITRC (Affiliated by GTU). I am good at learning new softwares. I enjoy meeting new people and finding ways to help them have an uplifting experience.
Career Objective
Looking for a challenging role in a reputable organization to utilize my technical, database, and management skills for the growth of the organization as well as to enhance my knowledge about new and emerging trends in the Computer sector.


When, in a database application, dealing with table names, there's many degrees
of freedom to deal with. For instance, suppose you want to have the full name of a
table object, as it should be used in a SELECT
statement's FROM
part. This requires you to evaluate whether or not the table has a catalog and/or schema
name, to combine the catalog, the schema, and the basic table name into one name, respecting
the database's quoting character, and the order in which all those parts should be combined.
Additionally, you have to respect the client-side settings which tell OpenOffice.org
to use or not use catalogs and schemas in SELECT
at all.
The XTableName interface eases this and other, similar tasks around table
names.
The component itself does not have life-time control mechanimns, i.e. you
cannot explicitly dispose it (::com::sun::star::lang::XComponent::dispose),
and you cannot be notified when it dies.
However, if your try to access any of its methods or attributes, after the
connection which was used to create it was closed, a ::com::sun::star::lang::DisposedException
will be thrown.


UNDOCUMENTED(1) Mono Manual UNDOCUMENTED(1) NAME caspol - No manpage for this program. DESCRIPTION This program does not have a manpage. Run this command with the help switch to see what it does. For further information, refer to the .NET documentation from the Mono project, located on http://www.go- mono.com/docs/ Debian GNU/Linux January 15th, 2004 UNDOCUMENTED(1)


WRAAM
Welcome,
Work Requests
Buildings
New Work Request
New Building
Register a New User
Change Your Password


ArcheAge puts the power of creation into the players hands. Every player can choose the life and legacy they build in this world. You can choose the simple life of a farmer, a fisherman, or a craftsman. Perhaps you want to be a merchant but not one of noble or pure intentions? Pirate other players on the open seas and fight the fierce monsters of the deep like the Kraken and the leviathan make your name feared as you send others to visit Davy Jones. If the simple life is not for you fighting might be more your pace, carving your way to the top of the gladiator arenas ranking, or fight in feirce battles with your fellow guildmates and countrymen to secure the bloody planes of Halcyona. Maybe you dream of grander things and want to lead your friends to conquering Auroria, building a castle and carving you guilds name onto the map. If you suceed you may even be able to declare your independance and form a nation all your own and defend it from other guilds and nations. In ArcheAge your story is yours to write.
Set in a fantasy world of magic and adventure and completely open with free travel between all zones, with a few dungeons, and openly contestable world bosses. Players are also able to own their own housing in designated areas of each zone and trade and sell things on a player driven auction system. The waters between continents are where the fun began, trade routes between factions lead to some really fun and unique battles on player owned and driven merchant and battleships. Alongside all these areas and events ArcheAge has one of the most unique class systems in the world of mmorpg’s; every character can change to any class at any time by selecting three skill trees of the ten in game totaling over one hundred and twenty different classes.
Crafting in ArcheAge created another avenue of character customization, even though it was heavily based on random chance, it offers different stat combinations and armor types for multiple styles of play. Later introduced was a crafting system that was cheaper and linear so it was more for the meta classes. Weapons and armor are both crafted from materials farmed on player land and with resources gained through international trading, the second crafting system or the obsidian system also require materials from the bosses and mobs that spawned in around the world.


From Web Components to React.JS and Node.JS. Check out my latest web software development portfolio projects.
Backend knowledge that includes local storage and database types
High level design that includes animations
Full stack programmer
I am 21 years old, I graduated from the army two months ago where I served in the ICT Corps, for the past year I studied programming independently and last January I enrolled in an academic coding course to improve my abilities and look for a job in the field


Open Banking Connector.NET
OpenBankingConnector.NET
Operation Complete
Tool or app using OpenBankingConnector.NET should close this window automatically


*** STOP: 0x00000000000001 (0x00000000000001,0x00000000000001,0x00000000000001)
*** Address 0x00000000000001 at base 0x00000000000001 is invalid. If this is the first time you've seen this stop message, go have a lie down.


The Open Immunization Software Project Tracker is a simple application for tracking public health projects.
Open Immunization Software - Immunization Registry Tester & Simple Message Mover


---
layout: post
title: Sketches for Zeppe
date: '2014-09-06T07:30:32+02:00'
categories:
- Character
picture_url: https://film-Storyboards.tumblr.com/post/96780951370/Sketches-for-zeppe
---
Zeppe & Zikki Sketches
Zeppe & Zikki Sketches
Zeppe & Zikki — Sketches
Sketches for Zeppe.


- Server - package Server
-
- Server - Class in Server
-
This is the entry of the server, including the main function and start and
stop method.
- Server() - Constructor for class Server.Server
-
- shutdown(int) - Method in class engine.Engine
-
Stop accepting new tasks and wait until all running tasks to finish.
- shutdownNow() - Method in class engine.Engine
-
Attempt to stop all running tasks immediately.
- start() - Method in class Server.Server
-
Start connector with default host(localhost) and default port(4444).
- start(int) - Method in class Server.Server
-
- start(String, int) - Method in class Server.Server
-
Start connector with specified host and port.
- STATUS_LINE_200 - Static variable in class Server.Server
-
- STATUS_LINE_201 - Static variable in class Server.Server
-
- STATUS_LINE_304 - Static variable in class Server.Server
-
- STATUS_LINE_400 - Static variable in class Server.Server
-
- STATUS_LINE_403 - Static variable in class Server.Server
-
- STATUS_LINE_404 - Static variable in class Server.Server
-
- STATUS_LINE_500 - Static variable in class Server.Server
-
- STATUS_LINE_501 - Static variable in class Server.Server
-
- stop() - Method in class Server.Server
-
Stop the server to accept new connection and wait all activated tasks to
complete until 10s elapsed, if timeout elapsed before termination, this
method will attempt to stop all tasks immediately, and then stop the
server.


Syncfusion is the enterprise technology partner of choice for Windows development, delivering a broad range of software frameworks and tools. Syncfusion has established itself as the trusted partner worldwide for use in mission-critical applications. Founded in 2001 and headquartered in Research Triangle Park, North Carolina, Syncfusion has more than 10,000 customers, including large financial institutions, Fortune 100 companies, and global IT consultancies.


{% extends "Hangman.html" %} {% block title %}Game{% endblock%} {% block intro %}Let's play!{% endblock %} {% block question %}
{{ question }}
Last choice:
Guessed letters:


--- layout: default ---
For additions or contributions to this Code Guide, please open an issue on GitHub.
Every line of code should appear to be written by a single person, no matter the number of contributors.
We do not "support" the following browsers:
Not supporting doesn't mean a broken website, it means a lack of testing.
We don't release code that hasn't been peer reviewed. Whether it's a two line change to some CSS or a complete refactoring of a JavaScript function, your pull request will always be reviewed by one of your peers.
Since all of your code is written on a different branch than master anyways, peer review is as simple as opening up a pull request and assigning it to somebody to review.
The only exception to committing code that isn't up to the standards in this document is when working on an older theme. It's preferable to keep code consistent to the theme that you're working on even if that code isn't up to our current standards (within reason). It's important to document these decisions in your Pull Request.
If the theme still has shelf life (not going to be archived any time soon), create a new task detailing the changes that should be made to bring the theme up to our current standards.
</li>
or </body>
).Enforce standards mode and more consistent rendering in every browser possible with this simple doctype at the beginning of every HTML page.
From the HTML5 spec:
Authors are encouraged to specify a lang attribute on the root html element, giving the document's language. This aids speech synthesis tools to determine what pronunciations to use, translation tools to determine what rules to use, and so forth.
Read more about the lang
attribute in the spec.
Head to Sitepoint for a list of language codes.
Internet Explorer supports the use of a document compatibility <meta>
tag to specify what version of IE the page should be rendered as. Unless circumstances require otherwise, it's most useful to instruct IE to use the latest supported mode with edge mode.
For more information, read this awesome Stack Overflow article.
Quickly and easily ensure proper rendering of your content by declaring an explicit character encoding. When doing so, you may avoid using character entities in your HTML, provided their encoding matches that of the document (generally UTF-8).
Per HTML5 spec, typically there is no need to specify a type
when including CSS and JavaScript files as text/css
and text/javascript
are their respective defaults.
Strive to maintain HTML standards and semantics, but not at the expense of practicality. Use the least amount of markup with the fewest intricacies whenever possible.
HTML attributes should come in this particular order for easier reading of code.
class
id
, name
data-*
src
, for
, type
, href
title
, alt
aria-*
, role
Classes make for great reusable components, so they come first. Ids are more specific and should be used sparingly (e.g., for in-page bookmarks), so they come second.
A boolean attribute is one that needs no declared value. XHTML required you to declare a value, but HTML5 has no such requirement.
For further reading, consult the WhatWG section on boolean attributes:
The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
If you must include the attribute's value, and you don't need to, follow this WhatWG guideline:
If the attribute is present, its value must either be the empty string or [...] the attribute's canonical name, with no leading or trailing whitespace.
In short, don't add a value.
Whenever possible, avoid superfluous parent elements when writing HTML. Many times this requires iteration and refactoring, but produces less HTML. Take the following example:
Writing markup in a JavaScript file makes the content harder to find, harder to edit, and less performant. Avoid it whenever possible.
Shopify is the only platform that we develop for that uses Liquid. Fortunately, they've done a great job on documentation and almost all of the info that you need can be found there.
The Objects link above is almost certainly the most important resource available to you when writing code for Shopify. It contains every single object you might come across during development and all of the values attached to them.
=
==
, !=
, <
, >
, etc.if
, unless
, and
, or
|
, minus:
, divided_by:
, strip
{% raw %}{{ }}{% endraw %}
, {% raw %}{% %}{% endraw %}
json
filter:
for each declaration.box-shadow
).rgb()
, rgba()
, hsl()
, hsla()
, or rect()
values. This helps differentiate multiple color values (comma, no space) from multiple property values (comma with space).0.5
instead of .5
and -0.5px
instead of -.5px
).#fff
. Lowercase letters are much easier to discern when scanning a document as they tend to have more unique shapes.#fff
instead of #ffffff
.input[type="text"]
. They’re only optional in some cases, and it’s a good practice for consistency.margin: 0;
instead of margin: 0px;
.Questions on the terms used here? See the syntax section of the Cascading Style Sheets article on Wikipedia.
[class^="..."]
) on commonly occuring components. Browser performance is known to be impacted by these.Additional reading:
Nesting is very helpful to define element states such as active and hover, pseudo elements like before and after, and minimal child selectors that don't justify an additional class name.
Variables in Sass are a powerful way to define values in one place that can be reused in multiple places in your project. They allow you to make changes from a central point without needing to use find and replace across multiple files and directories. [ref]
_user-settings.scss
.First, some basics:
This should be your first plan of attack. Using an @extend limits customizability but produces a more efficient CSS file. Smaller is better.
If you need to overwrite declarations of an @extend or need to pass values to it then you'll want to set up a mixin and use @include instead. Mixins are powerful and are generally used to accomplish complicated or labor-intensive tasks. Some examples:
Code is written and maintained by people. Ensure your code is descriptive, well commented, and approachable by others. Great code comments convey context or purpose. Do not simply reiterate a component or class name.
Be sure to write in complete sentences for larger comments and succinct phrases for general notes.
Place media queries inside their respective selector. Don't have entire blocks of code dedicated to a single media query.
Feel free to create a media query mixin to simplify modifying your queries.
In instances where a rule set includes only one declaration, consider removing line breaks for readability and faster editing. Any rule set with multiple declarations should be split to separate lines.
The key factor here is error detection—e.g., a CSS validator stating you have a syntax error on Line 183. With a single declaration, there's no missing it. With multiple declarations, separate lines is a must for your sanity.
Strive to limit use of shorthand declarations to instances where you must explicitly set all the available values. Common overused shorthand properties include:
padding
margin
font
background
border
border-radius
Often times we don't need to set all the values a shorthand property represents. For example, HTML headings only set top and bottom margin, so when necessary, only override those two values. Excessive use of shorthand properties often leads to sloppier code with unnecessary overrides and unintended side effects.
The Mozilla Developer Network has a great article on shorthand properties for those unfamiliar with notation and behavior.
.btn
and .btn-danger
)..btn
is useful for button, but .s
doesn't mean anything..js-*
classes to denote behavior (as opposed to style), but keep these classes out of your CSS.Thanks to compilation and compression, we're able to organize styles into many small files without impacting the end user. Rules should be organized into small sets corresponding to the elements they style. Styles of unrelated elements should never be in the same file.
Consider the example on the right.
This rule obviously hides something, but it's not clear what it's hiding, or why. This code is unmaintainable, because its purpose is not obvious. Strive to write selectors and styles whose purpose and relationship is intuitive and obvious.
Recommended only. During the course of development this might not be realistic. Try to keep the following recommendations in mind.
Related property declarations should be grouped together following the order:
Positioning comes first because it can remove an element from the normal flow of the document and override box model related styles. The box model comes next as it dictates a component's dimensions and placement.
Everything else takes place inside the component or without impacting the previous two sections, and thus they come last.
For a complete list of properties and their order, please see Recess.
Use spaces only, with 2 spaces per indentation level. Never mix tabs and spaces.
Try your best to limit all lines to a maximum of 80 characters. Do not ever go over 120.
Do not include trailing whitespace on any lines.
Use only unix-style newlines. \n
not \r\n
.
Use UTF-8 as the source file encoding.
Place 1 space before the leading brace.
Place 1 space before the opening parenthesis in control statements (if
, while
etc.). Place no space before the argument list in function calls and declarations.
Set off operators with spaces.
End files with a single newline character.
Leave a blank line after blocks and before the next statement.
Use a single blank line within the bodies of methods or functions in cases where this improves readability (e.g., for the purpose of delineating logical sections).
Do not use leading commas.
Use additional trailing commas.
This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don't have to worry about the trailing comma problem in legacy browsers.
Always use explicit semicolons.
Use braces with all multi-line blocks.
If you're using multi-line blocks with if and else, put else on the same line as your if block's closing brace.
Use const
for all of your references; avoid using var
.
This ensures that you can't reassign your references (mutation), which can lead to bugs and difficult to comprehend code.
If you must mutate references, use let
instead of var
.
let
is block-scoped rather than function-scoped like var
.
Note that both let
and const
are block-scoped.
Use one const
/let
declaration per variable.
Group all your const
s and then group all your let
s.
This is helpful when later on you might need to assign a variable depending on one of the previous assigned variables.
Use ===
and !==
over ==
and !=
.
Conditional statements such as the if statement evaulate their expression using coercion with the ToBoolean
abstract method and always follow these simple rules:
true
false
false
+0
, -0
, or NaN
, otherwise true
''
, otherwise true
Use shortcuts when possible.
Strings:
Use parseInt
for Numbers and always with a radix for type casting.
Booleans:
Avoid single letter names. Be descriptive with your naming.
Use camelCase when naming objects, functions, and instances.
Use PascalCase when naming constructors or classes.
Use a leading underscore _
when naming private properties or methods.
Don't save references to this
. Use arrow functions or Function#bind
.
If your file exports a single class, your filename should be exactly the name of the class.
Use camelCase when you export-default a function. Your filename should be identical to your function's name.
Use /** ... */
for multi-line comments. Include a description, specify types and values for all parameters and return values.
Use //
for single line comments. Place single line comments on a newline above the subject of the comment. Put an empty line before the comment.
Prefixing your comments with FIXME
or TODO
helps other developers quickly understand if you're pointing out a problem that needs to be revisited, or if you're suggesting a solution to the problem that needs to be implemented. These are different than regular comments because they are actionable.
Use // FIXME:
to annotate problems.
Use // TODO:
to annotate solutions to problems.
Use object destructuring when accessing and using multiple properties of an object.
Use array destructuring.
Use object destructuring for multiple return values, not array destructuring.
You can add new properties over time or change the order of things without breaking call sites.
Always use modules (import
/export
) over a non-standard module system. You can always transpile to your preferred module system.
Do not use wildcard imports.
Import statements should be grouped in the following order:
Use single quotes ''
for strings.
When programmatically building up strings, use template strings instead of concatenation.
Template strings give you a readable, concise syntax with proper newlines and string interpolation features.
Use the literal syntax for array creation.
Use Array#push
instead of direct assignment to add items to an array.
Use array spreads ...
to copy arrays.
To convert an array-like object to an array, use Array#from
.
Use function declarations instead of function expressions.
Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use Arrow Functions in place of function expressions.
Immediately-invoked function expressions:
Never declare a function in a non-function block (if
, while
, etc). Assign the function to a variable instead. Browsers will allow you to do it, but they all interpret it differently.
Never name a parameter arguments
. This will take precedence over the arguments
object that is given to every function scope.
Never use arguments
, opt to use rest syntax ...
instead.
Use default parameter syntax rather than mutating function arguments.
Use Object#assign
or jQuery#extend
to set default object values.
When you must use function expressions (as when passing an anonymous function), use arrow function notation.
It creates a version of the function that executes in the context of this
, which is usually what you want, and is a more concise syntax.
If you have a fairly complicated function, you might move that logic out into its own function declaration.
If the function body fits on one line and there is only a single argument, feel free to omit the braces and parentheses, and use the implicit return. Otherwise, add the parentheses, braces, and use a return statement.
Use the literal syntax for object creation.
Don't use reserved words as keys. It won't work in IE8. More info.
Use readable synonyms in place of reserved words.
Use computed property names when creating objects with dynamic property names.
They allow you to define all the properties of an object in one place.
Use object method shorthand.
Use property value shorthand.
Group your shorthand properties at the beginning of your object declaration.
Use dot notation when accessing properties.
Use subscript notation []
when accessing properties with a variable.
Always use class
. Avoid manipulating prototype
directly.
class
syntax is more concise and easier to reason about.
Use extends
for inheritance.
It is a built-in way to inherit prototype functionality without breaking instanceof
.
It's okay to write a custom toString()
method, just make sure it works successfully and causes no side effects.
Accessor functions for properties are not required.
If you do make accessor functions use getVal()
and setVal('hello')
.
If the property is a boolean, use isVal()
or hasVal()
.
It's okay to create get()
and set()
functions, but be consistent.
Getters and setters should not be used when supporting IE8 and below.
When attaching data payloads to events (whether DOM events or something more proprietary like Backbone events), pass a hash instead of a raw value. This allows a subsequent contributor to add more data to the event payload without finding and updating every handler for the event.
Prefix jQuery object variables with a $
.
Cache jQuery lookups.
If using a module system (CommonJS Modules, AMD, etc.), require statements should be placed on separate lines at the top of the file.
These statements should be grouped in the following order:
Avoid extraneous whitespace in the following situations:
Additional recommendations::
=
+=
, -=
, etc.==
, <
, >
, <=
, >=
, unless
, etc.+
, -
, *
, /
, etc.If modifying code that is described by an existing comment, update the comment such that it accurately reflects the new code. (If possible, improve the code to be clear and concise, and delete the comment entirely.)
The first word of the comment should be capitalized, unless the first word is an identifier that begins with a lower-case letter.
If a comment is short, the period at the end can be omitted.
#
and a single space, and should be indented at the same level of the code that it describes.#
.#
and a single space.Use camelCase
(with a leading lowercase character) to name all variables, methods, and object properties.
Use UpperCamelCase
(with a leading uppercase character) to name all classes.
(The official CoffeeScript convention is camelCase, because this simplifies interoperability with JavaScript. For more on this decision, see [here][coffeescript-issue-425].)
Methods and variables that are intended to be "private" should begin with a leading underscore.
(These guidelines also apply to the methods of a class.)
.
""
) instead of single quoted (''
) stringsunless
over if
for negative conditions, especially for trailing conditionsunless...else
, use if...else
Annotation types:
TODO
: describe missing functionality that should be added at a later dateFIXME
: describe broken code that must be fixedOPTIMIZE
: describe code that is inefficient and may become a bottleneckHACK
: describe the use of a questionable (or ingenious) coding practiceREVIEW
: describe code that should be reviewed to confirm implementationIf a custom annotation is required, the annotation should be documented in the project's README.
@property
over this.property
@
return
where not required, unless the explicit return increases clarity...
) when working with functions that accept variable numbers of argumentsUse single and double quotes when appropriate. If you’re not evaluating anything in the string, use single quotes. You should almost never have to escape quotes in a string, because you can just alternate your quoting style.
Text that goes into attributes should be run through esc_attr()
so that single or double quotes do not end the attribute value and invalidate the HTML and cause a security issue. See Data Validation in the Codex for further details.
Most theme-specific functions should be wrapped in a function_exists
test to allow child themes to override them. The function guard should use the alternative if endif
syntax.
Perl compatible regular expressions (PCRE, preg_
functions) should be used in preference to their POSIX counterparts. Never use the /e
switch, use preg_replace_callback
instead.
It’s most convenient to use single-quoted strings for regular expressions since, contrary to double-quoted strings, they have only two metasequences: \'
and \\
.
if
, elseif
, foreach
, for
, and switch
blocks.When formatting SQL statements you may break it into several lines and indent if it is sufficiently complex to warrant it. Most statements work well as one line though. Always capitalize the SQL parts of the statement like UPDATE
or WHERE
.
Functions that update the database should expect their parameters to lack SQL slash escaping when passed. Escaping should be done as close to the time of the query as possible, preferably by using $wpdb->prepare()
$wpdb->prepare()
is a method that handles escaping, quoting, and int-casting for SQL queries. It uses a subset of the sprintf()
style of formatting.
%s
is used for string placeholders and %d
is used for integer placeholders. Note that they are not ‘quoted’! $wpdb->prepare()
will take care of escaping and quoting for us. The benefit of this is that we don’t have to remember to manually use esc_sql()
, and also that it is easy to see at a glance whether something has been escaped or not, because it happens right when the query happens.
See Data Validation in the Codex for more information.
Avoid touching the database directly. If there is a defined function that can get the data you need, use it. Database abstraction (using functions instead of queries) helps keep your code forward-compatible and, in cases where results are cached in memory, it can be many times faster.
If you must touch the database, get in touch with some developers by posting a message to the wp-hackers mailing list. They may want to consider creating a function for the next WordPress version to cover the functionality you wanted.
Use lowercase letters in variable, action, and function names (never camelCase
). Separate words via underscores. Don’t abbreviate variable names un-necessarily; let the code be unambiguous and self-documenting.
Class file names should be based on the class name with class-
prepended and the underscores in the class name replaced with hyphens.
This file-naming standard is for all current and new files with classes. There is one exception for three files that contain code that got ported into BackPress: class.wp-dependencies.php, class.wp-scripts.php, class.wp-styles.php. Those files are prepended with class.
, a dot after the word class instead of a hyphen.
Files containing template tags in wp-includes
should have -template
appended to the end of the name so that they are obvious.
Prefer string values to just true
and false
when calling functions.
Since PHP doesn’t support named arguments, the values of the flags are meaningless, and each time we come across a function call like the examples above, we have to search for the function definition. The code can be made more readable by using descriptive string values, instead of booleans.
Ternary operators are fine, but always have them test if the statement is true, not false. Otherwise, it just gets confusing. (An exception would be using ! empty()
, as testing for false here is generally more intuitive.)
When doing logical comparisons, always put the variable on the right side, constants or literals on the left.
In the above example, if you omit an equals sign (admit it, it happens even to the most seasoned of us), you’ll get a parse error, because you can’t assign to a constant like true
. If the statement were the other way around ( $the_force = true )
, the assignment would be perfectly valid, returning 1
, causing the if statement to evaluate to true
, and you could be chasing that bug for a while.
A little bizarre, it is, to read. Get used to it, you will.
This applies to ==
, !=
, ===
, and !==
. Yoda conditions for <
, >
, <=
or >=
are significantly more difficult to read and are best avoided.
At its most basic, source control gives us the ability to store, share, and transport code and code changes, but the real value comes from the ability to record and replay the stories behind each change during the lifetime of a project.
This is not an intro to source control or a git how-to: we assume that you have an intermediate understanding of how to use git. If you’re new to git, chapters 2, 3, and 6 (through the section on interactive rebasing) of Scott Chacon’s git book will tell you the how.
It doesn’t matter if you use git’s commands or a GUI (see GitHub for Mac and Gitbox), but you need a confident understanding of what’s happening regardless. Knowing the commands often helps.
To keep our many repositories easy to find we follow a simple naming convention:
Things to do right away:
Never commit directly to master. Instead, create small branches for each and every topic you work on (such as a feature or bug fix), and create a pull request into master when the branch is complete.
The exception to this rule is version commits and tags.
If your branch cannot be named as a specific function/feature/bug then you can create a long-running branch with a name like multiple_fixes
.
When using this method, it's important that the commits are clear and minimal (see Commits).
Please read Stephen Ball’s Steel City Ruby 2013 presentation, Deliberate Git. It covers this topic very well.
Once you’ve read it, you’ll understand why you should:
WIP
is fine.When writing commits:
If you’re pushing a new branch, use the --set-upstream
(-u
) flag to automatically set the remote branch as your local branch’s tracking branch.
So your pull request has been peer-reviewed and approved – nice work! Now it's time to merge your changes into master.
You want to use a fast-forward merge (git merge --ff-only
). Merging this way prevents "merge bubbles" where commit messages are created that say that a branch has been merged. This is called a recursive merge and it muddies up the commit history.
Versioned libraries, both internal and public, should follow these practices:
major_feature.minor_feature/major_bugfix.minor_bugfix
numbering schemev


welcome
This demo - records your webcam (using HTML5 APIs) and the webpage (using RRWeb library). - webcam recordings are split in multiple segments (every 30s, configurable) and uploaded to the server - webpage recording are uploaded at the end of the session - the session ends after 45 seconds Inspect the js console and network panel for more details.


This page features Ten Thousand Years by Goddamn Electric Bill, and You Should Know Better by St. Lucia.


{% load static %}
Real State In Nepal
Home
Categories
Pradesh 1
Morang
3rd level
Pradesh 2
2nd level
3rd level
Pradesh 3
News
Contact Us
Properties In Morang
Tinkune,Kathmandu
Rs.3,40,00,000
4,250 sqft.
Chitwan-2,Nepal
Rs.3,40,00,000
7,250 sqft.
Lamachaur-16,Pokhara
Rs.2,400,000
4,250 sqft.
Nayathimi,Bhaktapur
Rs.5,40,00,000
7,250 sqft.
Siraha-6,Nepal
$40,00,000
1,250 sqft.
View All Property Listings
Contact Us
Contact Form
Name
Email
Subject
Message
Send Message
Address
Lamachaur-16,Pokhara,Nepal
Phone
9824793101/9814279681/9807775098
Email Address
mahaseth.aman123@gmail.com


Welcome to my Portfolio. I am a graduated full stack developer. An enthusiastic and motivated individual who wants to explore the new areas and work in a dynamic stable organization.
I want to work for an organization which provides me the opportunity to improve my skills and knowledge to growth along. You can contact me if you want to know further about me. I would love to answer your questions. Details are given below. Thanks for visiting my Profile :)
This is the skillset that I know about and I've worked with it also.
I am a self-taught Front End Developer. I can work with HTML5,CSS3,Php,Javascript and React.js
I am quite familiar with Php and javascript. I have build some projects during my learning period.
Currently I'm improving my knowledge on React.js. I'm creating some toy projects to sharp my skills.
Node.js is something I know about it. And gradually I'm moving towards learning process of Node.js
I would love to answer your queries. I will look forward to hear from you


--- layout: post title: Two UK companies looking for Rails programmers categories: [] author: admin published: true date: 2005-07-19 09:46:20.000000000 +01:00 ---
The population of professional Ruby on Rails developers is calling for growth:


--- layout: post title: "TimeSpan configuration values in .NET Core" description: "You can use a standard string format for TimeSpan values in configuration files." date: 2019-11-25 7:04 UTC tags: [Miscellaneous] --- {% include JB/setup %}
{{ page.description }}
Sometimes you need to make TimeSpan
values configurable. I often see configuration files that look like this:
{ "SeatingDurationInSeconds": "9000" }
Code can read such values from configuration files like this:
var seatingDuration = TimeSpan.FromSeconds(Configuration.GetValue<int>("SeatingDurationInSeconds"));
This works, but is abstruse. How long is 9000 seconds?
The idiomatic configuration file format for .NET Core is JSON, which even prevents you from adding comments. Had the configuration been in XML, at least you could have added a comment:
<!--9000 seconds = 2½ hours--> <SeatingDurationInSeconds>9000</SeatingDurationInSeconds>
In this case, however, it doesn't matter. Use the standard TimeSpan string representation instead:
{ "SeatingDuration": "2:30:00" }
Code can read the value like this:
var seatingDuration = Configuration.GetValue<TimeSpan>("SeatingDuration");
I find a configuration value like "2:30:00"
much easier to understand than 9000
, and the end result is the same.
I haven't found this documented anywhere, but from experience I know that this capability is present in the .NET Framework, so I wondered if it was also available in .NET Core. It is.
Comments
There is actually an ISO 8601 standard for durations.
In your example you can use
or which is also quite readable in my opinion.Not every JSON serializer supports it though.
Rex, thank you for writing. I was aware of the ISO standard, although I didn't know that you can use it in a .NET Core configuration file. This is clearly subjective, but I don't find that format as readable as
2:30:00
.