Look a little bit of very short demo. 2
The purpose of this demo is to show that when we are reading from a text file we need to use the same 3
encoding scheme as the text file. 4
Ok so the text file has certain encoding scheme which means that the text in the file has been anchored 5
using that encoding scheme. 6
Now when we are reading from that file we also need to use the same encoding scheme. 7
OK otherwise it's not going to work correctly. 8
So let's just go ahead and best that on this matter. 9
New method is called as encoding sync which means that we want to keep the encoding schemes in sync 10
. 11
So here it's just a buffered reader and we are reading from this file. 12
Karla's encoding are in the file this year and garding and it just has one line on only one character 13
which is a euro and under-five itself is encoded using u d of 8 came here of eight. 14
Now we will. 15
And the encoding that we are specifying here is also Eudy of 8. 16
So let's just run this and you can see that we have the Euro symbol which is fine. 17
Now if we change this to let's say you have 16 big endian. 18
Now if we run it. 19
So it's not giving us the correct text. 20
OK. 21
So that's the problem. 22
So we need to always read using the same kind of encoding scheme. 23
Now let's just try the same thing in a slightly more fancier way. 24
So here is the court. 25
And here we are doing the same thing we are building a string and the string that we want to construct 26
is a Euro symbol. 27
And this particular string constructor it has two parameters one is a byte. 28
Ari on the other one is the carter sec. 29
Carter satiny 100 basically constructs a null string. 30
Ok it's going to construct a null string by decoding the specified by Dhari. 31
So we have this Bidar as a parameter. 32
So it's going to be correct using the specified characters section and the baby are generating the bite 33
array itself. 34
And this way so you have the strength Eudo and we are in Wolken to get bytes metor on that string. 35
And the goodbye to moderate returns the binary and uses this encoding scheme. 36
OK so it's going to get better but that is going to encode this string using this character set it is 37
going to return a sequence of match. 38
And the string whether constructor is going to be coded using using the descriptor encoding scheme. 39
So this is going to be called and this is actually encoding. 40
So this is like reading from a fine. 41
So if we do this or just run this so it gives the euro's human once again. 42
Make it 43
and it's not going to work. 44
So that's the thing. 45
And here is the same thing but we are using that kind of power. 46
And this is us aski. 47
Now this is Aski And if we see it prints it. 48
And that's because you'll be of eight is backward compatible with us ascii. 49
Now let's make it 16 b and this should not work because you have 16 of 16 is not backward compatible 50
with US-ASCII. 51
OK. 52
Only UTF 8 is backward compatible. 53
So just wanted to show these two things and that's it. 54
Thank you