js_set_encode(3)

NAME
js_set_encode - change the encoding that a given js_string object uses

SYNOPSIS
#include JsStr.h

int js_set_encode(js_string *js, int encoding);

DESCRIPTION
js_set_encode changes the encoding that a given js_string object uses. In other words, you can use this function to set the encoding of a js_string object to ASCII or BINARY. Eventually, this function will allow you to set the encoding to UNICODE-3, ISO 8859-1, etc.

ARGUMENTS
js is a pointer to the js_string object that you wish to change the encoding for.

encoding is the type of coding the js_string object's string contains. Currently supported values are JS_BINARY for binary data, and JS_US_ASCII for data encoded in US ASCII format.

EXAMPLE
The following example code creates a js_string object, and, in series, sets the encoding to ASCII, then to binary data.

	js_string *foo;
	foo = js_create(256,1);         /* Encoding starts off binary */
	js_set_encode(foo,JS_US_ASCII); /* Encoding is now ASCII */
	js_set_encode(foo,JS_BINARY);   /* Encoding is binary again */

RETURN VALUE
js_set_encode returns JS_SUCCESS on success, and JS_ERROR if it is not able to set the encoding for the js_string object.

NOTES
A newly created js_string object has a default encoding of JS_BINARY

BUGS
This function does not change the size of octets for a js_string object. Since all presently supported encodings use a single octet to represent a character, this is currently a non-issue.

AUTHOR
Sam Trenholme <kiwi-zttfryb@koala.samiam.org>