React Native
React Native
URL Encoding and Decoding
See more Encryption Examples
Demonstrates URL encoding and decoding.Chilkat React Native Downloads
import { StringBuilder } from '@chilkat/react-native'
function chilkatExample() {
// To URL encoding a string:
const s = 'Why a > b?';
const sb = new StringBuilder();
sb.append(s);
// URL encode the string.
sb.encode('url', 'utf-8');
// Show the URL encoded string:
const sEncoded = sb.getAsString();
console.log(sEncoded);
// The result is: Why%20a%20%3E%20b%3F
// If you prefer "+" instead of "%20" for SPACE chars:
const numReplaced = sb.replace('%20', '+');
console.log(sb.getAsString());
// Output is: Why+a+%3E+b%3F
// To decode:
sb.decode('url', 'utf-8');
console.log(sb.getAsString());
// Result is: Why a > b?
}