Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- System.Text.ASCIIEncoding.ASCII.GetBytes
- System.Convert.ToBase64String
- System.Convert.FromBase64String
- System.Text.ASCIIEncoding.ASCII.GetString
- $(document).ready( function() {
- $('form').bind('submit', function() {
- $('form' > 'input[type=text]').each( function(i) {
- if (this.value) {
- this.value = encode(this.value);
- }
- });
- });
- });
- function encode(value) {
- return ...suitable encoding...
- }
- <script type="text/javascript">
- var unencodedText = "This is my text that contains whitespaces and characters like and Ø";
- var encodedText = "";
- var decodedText = "";
- alert('unencodedText: ' + unencodedText);
- //To encode whitespaces and the 'Ø' character - use encodeURI
- encodedText = encodeURI(unencodedText);
- //We see that whitespaces and 'Ø' are encoded, but the '' is still there:
- alert('encodedText: ' + encodedText);
- //If we decode it we should get our unencodedText back
- decodedText = decodeURI(encodedText);
- alert('decodedText: ' + decodedText);
- //To also encode the '' we use the encodeURIComponent
- encodedText = encodeURIComponent(unencodedText);
- //Now all the characters have been encoded:
- alert('encodedText: ' + encodedText);
- //To get our unencodedText back we now need to use the decodeURIComponent
- decodedText = decodeURIComponent(encodedText);
- alert('decodedText: ' + decodedText);
- </script>
Add Comment
Please, Sign In to add comment