Whitebeam Object Definition

Site Map
 
Home
 
Application Guide
Reference
  Installation
  Configuration
  XML Markup
  JavaScript Classes
  ROM
  Templates
  Environment
  Dev Process
  Tools
  External Links
  Example libraries
Community
Contact Whitebeam
To-Do
Download
Credits
Licence
Whitebeam Users
 
 
 

Whitebeam Object Definition

Method Description

WbString.toUTF8()

Produce a UTF-8 encoding string of the argument.

See Also

WbString.fromUTF8()   

Syntax

WbString = WbString.toUTF8(input_string)

Parameters

The 'WbString.toUTF8' method takes 1 parameter:

Name Type/Value Range/Length Description
input_stringstring  Required. String to be encoded

Results

The 'WbString.toUTF8' method returns WbString:

Type/Value Range/Length Description
WbString   Returns a WbString instance containing the UTF-8 encoded form of the string argument

Remarks

Encode a string into a valid UTF-8 form

Note: This is a method method on WbString and so is invoked as WbString.toUTF8(str);

Javascript stores all strings in UTF-16 allowing it to encode a vast range of characters. When these characters are sent to a web-site they are usually sent as a sequence of 8 bit characters, often using the Latin-1 (for Western sites) or UTF-8 encoding.

In many cases, especially for English sites, simply sending the Javascript string to the browser using rb.page.write is adequate. In this case the first byte of each character is transmitted. All ASCII characters will appear correctly at the remote end.

Where an extended character set is required you can use this method to transcribe the UTF-16 characters held in Javascript into a valid UTF-8 string and hence preserving the full range of characters. Note you will need to tell the browser through appropriate HTML headers that the characters you are sending are UTF-8.

If you are generating XML then all XML decuments should be UTF-8 encoded.

Generally AJAX exchanges will use the UTF-8 encoding.

The method returns a new WbString instance that to all intents and purposes can be treated as a standard Javascript string object.

Whitebeam release 1.3.36
(loadtime : 10ms)