SlideShare une entreprise Scribd logo
1  sur  11
Encoding in JavaScript fahai [at] TaobaoUED
ECMA 262 - §6 ECMAScript source text is represented as a sequence of characters in the Unicode character encoding, version 2.1 or later, using the UTF-16 transformation format. The text is expected to have been normalised to Unicode Normalised Form C (canonical composition), as described in Unicode Technical Report #15. Conforming ECMAScript implementations are not required to perform any normalisation of text, or behave as though they were performing normalisation of text, themselves.
SourceCharacter :: any Unicode character
Rhino Book - §3.2 JavaScript programs are written using the Unicode character set. Although the ECMAScript v3 standard allows Unicode characters anywhere in a JavaScript program, versions 1 and 2 of the standard allow Unicode characters only in comments and quoted string literals; all elements are restricted to the ASCII character set. Versions of JavaScript that predate ECMAScript standardization typically do not support Unicode at all.
Code-point, not byte
Example var草泥马 = function() { this.constructor.prototype.咆哮 = function(叫声) {         alert(叫声);     }; }; new 草泥马().咆哮("除尽天下河蟹日,家祭无忘告乃翁!");
Example alert(String.fromCharCode(35201, 21644, 35856, 65292, 35201, 26377, 29233));
related functions escape() encodeURI() encodeURIComponent()
Reference ECMAScript Specification - 3rd Edition JavaScript - The Definition Guide - 5th Edition
Thanks

Contenu connexe

En vedette

Rendering in browser
Rendering in browserRendering in browser
Rendering in browserPu Shiming
 
Nips yomikai 1226
Nips yomikai 1226Nips yomikai 1226
Nips yomikai 1226Yo Ehara
 
LeSS in action
LeSS in actionLeSS in action
LeSS in actionPu Shiming
 
Acl yomikai, 1016, 20110903
Acl yomikai, 1016,  20110903Acl yomikai, 1016,  20110903
Acl yomikai, 1016, 20110903Yo Ehara
 
Mars attack 2010-07-16
Mars attack 2010-07-16Mars attack 2010-07-16
Mars attack 2010-07-16Pu Shiming
 
Pagelet in action
Pagelet in actionPagelet in action
Pagelet in actionPu Shiming
 
Mars attack 2011-04-15
Mars attack 2011-04-15Mars attack 2011-04-15
Mars attack 2011-04-15Pu Shiming
 
Mobilize your Retail Customer Experience with iBeacons and Proximity Marketing
Mobilize your Retail Customer Experience with iBeacons and Proximity MarketingMobilize your Retail Customer Experience with iBeacons and Proximity Marketing
Mobilize your Retail Customer Experience with iBeacons and Proximity Marketingjimwebster1
 
VISUG: Visual studio for web developers
VISUG: Visual studio for web developersVISUG: Visual studio for web developers
VISUG: Visual studio for web developersKevin DeRudder
 
Employee Perception Towards Organization Change
Employee Perception Towards Organization ChangeEmployee Perception Towards Organization Change
Employee Perception Towards Organization ChangeAshish Kumar
 
Charset and encoding
Charset and encodingCharset and encoding
Charset and encodingPu Shiming
 
Innovative Changes In Human Resource Management
Innovative Changes In Human Resource ManagementInnovative Changes In Human Resource Management
Innovative Changes In Human Resource ManagementAshish Kumar
 
Icml yomikai 07_16
Icml yomikai 07_16Icml yomikai 07_16
Icml yomikai 07_16Yo Ehara
 
Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)Pu Shiming
 

En vedette (17)

Rendering in browser
Rendering in browserRendering in browser
Rendering in browser
 
Nips yomikai 1226
Nips yomikai 1226Nips yomikai 1226
Nips yomikai 1226
 
Case study
Case studyCase study
Case study
 
LeSS in action
LeSS in actionLeSS in action
LeSS in action
 
Acl yomikai, 1016, 20110903
Acl yomikai, 1016,  20110903Acl yomikai, 1016,  20110903
Acl yomikai, 1016, 20110903
 
Mars attack 2010-07-16
Mars attack 2010-07-16Mars attack 2010-07-16
Mars attack 2010-07-16
 
Pagelet in action
Pagelet in actionPagelet in action
Pagelet in action
 
Mars attack 2011-04-15
Mars attack 2011-04-15Mars attack 2011-04-15
Mars attack 2011-04-15
 
Dpl in action
Dpl in actionDpl in action
Dpl in action
 
Mobilize your Retail Customer Experience with iBeacons and Proximity Marketing
Mobilize your Retail Customer Experience with iBeacons and Proximity MarketingMobilize your Retail Customer Experience with iBeacons and Proximity Marketing
Mobilize your Retail Customer Experience with iBeacons and Proximity Marketing
 
VISUG: Visual studio for web developers
VISUG: Visual studio for web developersVISUG: Visual studio for web developers
VISUG: Visual studio for web developers
 
Employee Perception Towards Organization Change
Employee Perception Towards Organization ChangeEmployee Perception Towards Organization Change
Employee Perception Towards Organization Change
 
Charset and encoding
Charset and encodingCharset and encoding
Charset and encoding
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 
Innovative Changes In Human Resource Management
Innovative Changes In Human Resource ManagementInnovative Changes In Human Resource Management
Innovative Changes In Human Resource Management
 
Icml yomikai 07_16
Icml yomikai 07_16Icml yomikai 07_16
Icml yomikai 07_16
 
Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)
 

Similaire à Encoding in javascript

basic c++(1)
basic c++(1)basic c++(1)
basic c++(1)sajidpk92
 
c++ Lecture 1
c++ Lecture 1c++ Lecture 1
c++ Lecture 1sajidpk92
 
Structure-Compiler-phases information about basics of compiler. Pdfpdf
Structure-Compiler-phases information  about basics of compiler. PdfpdfStructure-Compiler-phases information  about basics of compiler. Pdfpdf
Structure-Compiler-phases information about basics of compiler. Pdfpdfovidlivi91
 
C Language Compiler in Python c language compiler using python
C Language Compiler in Python c language compiler using pythonC Language Compiler in Python c language compiler using python
C Language Compiler in Python c language compiler using pythonAmmarAhmed900673
 
object oriented programming in java lecture
object oriented programming in java lectureobject oriented programming in java lecture
object oriented programming in java lectureMSohaib24
 
The scanner performs lexical analysis of a precise program (in our c.pdf
The scanner performs lexical analysis of a precise program (in our c.pdfThe scanner performs lexical analysis of a precise program (in our c.pdf
The scanner performs lexical analysis of a precise program (in our c.pdfanujmkt
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docxvenkatapranaykumarGa
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)omercomail
 

Similaire à Encoding in javascript (15)

basic c++(1)
basic c++(1)basic c++(1)
basic c++(1)
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
c++ Lecture 1
c++ Lecture 1c++ Lecture 1
c++ Lecture 1
 
Wasm intro
Wasm introWasm intro
Wasm intro
 
Unit1 cd
Unit1 cdUnit1 cd
Unit1 cd
 
Structure-Compiler-phases information about basics of compiler. Pdfpdf
Structure-Compiler-phases information  about basics of compiler. PdfpdfStructure-Compiler-phases information  about basics of compiler. Pdfpdf
Structure-Compiler-phases information about basics of compiler. Pdfpdf
 
C Language Compiler in Python c language compiler using python
C Language Compiler in Python c language compiler using pythonC Language Compiler in Python c language compiler using python
C Language Compiler in Python c language compiler using python
 
LANGUAGE TRANSLATOR
LANGUAGE TRANSLATORLANGUAGE TRANSLATOR
LANGUAGE TRANSLATOR
 
CD U1-5.pptx
CD U1-5.pptxCD U1-5.pptx
CD U1-5.pptx
 
7068458.ppt
7068458.ppt7068458.ppt
7068458.ppt
 
object oriented programming in java lecture
object oriented programming in java lectureobject oriented programming in java lecture
object oriented programming in java lecture
 
The scanner performs lexical analysis of a precise program (in our c.pdf
The scanner performs lexical analysis of a precise program (in our c.pdfThe scanner performs lexical analysis of a precise program (in our c.pdf
The scanner performs lexical analysis of a precise program (in our c.pdf
 
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
2-Design Issues, Patterns, Lexemes, Tokens-28-04-2023.docx
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
 
Compiler design
Compiler designCompiler design
Compiler design
 

Encoding in javascript

  • 1.
  • 2. Encoding in JavaScript fahai [at] TaobaoUED
  • 3. ECMA 262 - §6 ECMAScript source text is represented as a sequence of characters in the Unicode character encoding, version 2.1 or later, using the UTF-16 transformation format. The text is expected to have been normalised to Unicode Normalised Form C (canonical composition), as described in Unicode Technical Report #15. Conforming ECMAScript implementations are not required to perform any normalisation of text, or behave as though they were performing normalisation of text, themselves.
  • 4. SourceCharacter :: any Unicode character
  • 5. Rhino Book - §3.2 JavaScript programs are written using the Unicode character set. Although the ECMAScript v3 standard allows Unicode characters anywhere in a JavaScript program, versions 1 and 2 of the standard allow Unicode characters only in comments and quoted string literals; all elements are restricted to the ASCII character set. Versions of JavaScript that predate ECMAScript standardization typically do not support Unicode at all.
  • 7. Example var草泥马 = function() { this.constructor.prototype.咆哮 = function(叫声) { alert(叫声); }; }; new 草泥马().咆哮("除尽天下河蟹日,家祭无忘告乃翁!");
  • 8. Example alert(String.fromCharCode(35201, 21644, 35856, 65292, 35201, 26377, 29233));
  • 9. related functions escape() encodeURI() encodeURIComponent()
  • 10. Reference ECMAScript Specification - 3rd Edition JavaScript - The Definition Guide - 5th Edition