String manipulation functions help you get information about a string as well as convert a string from Latin 1 encoding to platform-native encoding and back.

dreamweaver.doURLEncoding()

Availability

Dreamweaver 1.

Description

Takes a string and returns a URL-encoded string by replacing all the spaces and special characters with specified entities.

Arguments

stringToConvert

  • The stringToConvert argument is a string that contains the unencoded URL that the function encodes.

Returns

A URL-encoded string.

Example

The following example shows the URL.value for "My URL-encoded string":

 var URL = dw.doURLEncoding(theURL.value); 
returns "My%20URL-encoded%20string"

dreamweaver.getTokens()

Availability

Dreamweaver 1.

Description

Accepts a string and splits it into tokens.

Arguments

searchString, separatorCharacters

  • The searchString argument is the string to separate into tokens.

  • The separatorCharacters argument is the character or characters that signifies the end of a token. Separator characters in quoted strings are ignored. Any white-space characters that occur in separatorCharacters (such as tabs) are treated as separator characters, as if they are explicitly specified. Two or more consecutive white space characters are treated as a single separator.

Returns

An array of token strings.

Example

The following call to the dw.getTokens() function returns the tokens that come after it:

dreamweaver.getTokens('foo("my arg1", 34)', '(),')

  • foo

  • "my arg 1"

  • 34

dreamweaver.latin1ToNative()

Availability

Dreamweaver 2.

Description

Converts a string in Latin 1 encoding to the native encoding on the user’s computer. This function is intended to display the UI of an extension file in another language.

Note:

This function has no effect in Windows because Windows encodings are already based on Latin 1.

Arguments

stringToConvert

  • The stringToConvert argument is the string to convert from Latin 1 encoding to native encoding.

Returns

The converted string.

dreamweaver.nativeToLatin1()

Availability

Dreamweaver 2.

Description

Converts a string in native encoding to Latin 1 encoding.

Note:

This function has no effect in Windows because Windows encodings are already based on Latin 1.

Arguments

stringToConvert

  • The stringToConvert argument is the string to convert from native encoding to Latin 1 encoding.

Returns

The converted string.

dreamweaver.scanSourceString()

Availability

Dreamweaver UltraDev 1.

Description

Scans a string of HTML and finds the tags, attributes, directives, and text. For each tag, attribute, directive, and text span that it finds, the scanSourceString() function starts a callback function that you must supply. Dreamweaver supports the following callback functions:

  • openTagBegin()

  • openTagEnd()

  • closeTagBegin()

  • closeTagEnd()

  • directive()

  • attribute()

  • text()

Dreamweaver calls the seven callback functions on the following occasions:

  • Dreamweaver calls openTagBegin() for each opening tag (for example, <font>, as opposed to </font>) and each empty tag (for example, <img> or <hr>). The openTagBegin() function accepts two arguments: the name of the tag (for example, "font" or "img") and the document offset, which is the number of bytes in the document before the beginning of the tag. The function returns true if scanning should continue or false if it should stop.

  • After openTagBegin() executes, Dreamweaver calls attribute() for each HTML attribute. The attribute() function accepts two arguments, a string that contains the attribute name (for example, "color" or "src") and a string that contains the attribute value (for example, "#000000" or "foo.gif"). The attribute() function returns a Boolean value that indicates whether scanning should continue.

  • After all the attributes in the tag have been scanned, Dreamweaver calls openTagEnd(). The openTagEnd() function accepts one argument, the document offset, which is the number of bytes in the document before the end of the opening tag. It returns a Boolean value that indicates whether scanning should continue.

  • Dreamweaver calls closeTagBegin() for each closing tag (for example, </font>). The function accepts two arguments, the name of the tag to close (for example, "font") and the document offset, which is the number of bytes in the document before the beginning of the closing tag. The function returns a Boolean value that indicates whether scanning should continue.

  • After closeTagBegin() returns, Dreamweaver calls the closeTagEnd() function. The closeTagEnd() function accepts one argument, the document offset, which is the number of bytes in the document before the end of the closing tag. It returns a Boolean value that indicates whether scanning should continue.

  • Dreamweaver calls the directive() function for each HTML comment, ASP script, JSP script, or PHP script. The directive() function accepts two arguments, a string that contains the directive and the document offset, which is the number of bytes in the document before the end of the closing tag. The function returns a Boolean value that indicates whether scanning should continue.

  • Dreamweaver calls the text() function for each span of text in the document (that is, everything that is not a tag or a directive). Text spans include text that is not visible to the user, such as the text inside a <title> or <option> tag. The text() function accepts two arguments, a string that contains the text and the document offset, which is the number of bytes in the document before the closing of the closing tag. The text() function returns a Boolean value that indicates whether scanning should continue.

Arguments

HTMLstr, parserCallbackObj

  • The HTMLstr argument is a string that contains code.

  • The parserCallbackObj argument is a JavaScript object that has one or more of the following methods: openTagBegin(), openTagEnd(), closeTagBegin(), closeTagEnd(), directive(), attribute(), and text(). For best performance, parserCallbackObj should be a shared library that is defined using the C-Level Extensibility interface. Performance is also improved if parserCallbackObj defines only the callback functions that it needs.

Returns

A Boolean value: true if the operation completed successfully; false otherwise.

Example

The following sequence of steps provide an example of how to use the dreamweaver.scanSourceString() function:

  1. Create an implementation for one or more of the seven callback functions.

  2. Write a script that calls the dreamweaver.scanSourceString() function.

  3. The dreamweaver.scanSourceString() function passes a string that contains HTML and pointers to the callback functions that you wrote. For example, the string of HTML is "<font size=2>hello</font>".

  4. Dreamweaver analyzes the string and determines that the string contains a font tag. Dreamweaver calls the callback functions in the following sequence:

    • The openTagBegin() function

    • The attribute() function (for the size attribute)

    • The openTagEnd() function

    • The text() function (for the "hello" string)

    • The closeTagBegin() and closeTagEnd() functions

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy