In this lesson, we are looking at encoding, decoding, you are eyes so we can do an encode decode,
you are a component as well as encode decode you are eyes.
So what's the difference?
It's the characters that get escaped.
So with you encode, you are a component.
So if you use that method, all the escapes, all characters except the ones below, and this is how
you can write that.
So getting the Windows location, you can encode you are all using the UI component and you can see
what the difference here is.
Also, there's some documentation, of course, that the Mozilla developer network, so they're using
nine regular characters and you can see how this gets encoded as well as test.
So test is probably more relevant for what you're doing.
You can see test X equals test.
So this is how it looks like within the string and then encode it.
It looks like this.
So it escapes certain characters and outputs them within a more readable format.
So when you pick it up on the other end, you don't have characters that you might not be able to utilize.
Also, we're able to check to see if it contains components so we can see if you are a X is not equal
to the code, you are a component X..
We can see which characters are being included because of the difference between the two ways.
So let's look at this in a little bit more depth.
Opening up our Ed and we're going to get the window location.
So using window object and then location, it's going to return back to the location.
And this is the graph.
And we can console log that out just as we take it in.
So this is just the regular you are RL and then we can encode it.
So encode you are L and using this time we're going to use encode you are a you are a component.
So taking the URL and then we also have an option to decode the euro.
So using and code or actually there should be decode of course that you are a component.
And then here if we pass in the one that we just encoded, we should be able to retrieve back that same
one.
So encoding, decoding, we can put it in and encode it format and then we can also pull it out of that
encoded format.
And this is useful when you are programming, because you are going to find that in some cases you do
need to transform your string into more into different types of formats.
So you see that we get our original URL, it gets passed in and then it gets decoded again.
So encoded, decoded.
And there's also an option as well to use your URL and just encode the UI.
So this one is actually more common and I'll show you how that one works so we can pass in a new URL
for that one.
So let's set up a new URL.
And this is what I'm just going to use your Ellisville website.
And then this particular website is taking in some parameters.
So it's got an ID and it's got some other stuff.
So more than Hello World and make sure we have a space in there and put it into the console.
So right now we're just going to encode it directly.
So we've got our encode, you or I.
So this is slightly different as you're going to see, because there's different characters that are
being escape.
So when we encode it, then you see that the big difference here is that the space turned into a percentage
20 and the rest of it pretty much remained intact.
So if we were to take that and if we were to decode that, so without making any changes, if we just
do a decode on that you URL, you're going to see that nothing changes.
So we could pass it in and we could take it out and decode it.
So if we want to pass in the encoded value and then decode that ARACY, nothing changes because we're
able to encode, decode and decode obviously does the opposite of encode.
So there is a difference.
If we take a console log and we do an encode, you are I component.
So there is going to be a difference in the URL and you see that it's encoded the HTTP.
So it's gotten the call and it's gotten the Ford slashes and it's encoded everything.
So this one might not be as useful, but they both are available in case you need them within your coding
to restructure some of the wording.
So the other one that encode you are I, I doesn't escape these characters.
So there's more characters that don't get escaped as opposed to that encode.
You are a component.
So there is a challenge for this one.
And that's to take your favorite website and code.
You are with the URL and then also encode your eye component with the URL and the source code is below.
You can try this out and it's going to be the exact same example that I've just shown.