How to encode a string into URL encode
Hello I want to encode the string into URL encode like in OB
I'm looking for a function or a piece of code that can perform the above mention task.
If anybody knows about it let me know in the comments.
here is the string that I want to encode
and here is the OB result
Note: I want to perform the above task in C# or vb.net
As you know, OB is open source, so you can simply CTRL+F the repository on github for URLEncode and copy the snippet ^_^
Anyways, if your string is shorter than 2083 characters you can do
var urlEncoded = Uri.EscapeDataString(plainText);
Otherwise you have to split it in chunks and then encode each chunk
var urlEncoded = string.Join("", SplitInChunks(plainText, 2080).Select(s => Uri.EscapeDataString(s)));
SplitInChunksis a function I made, you can find it here https://github.com/openbullet/openbullet/blob/8ada4c3c394f9c0e01637387d0cf5a20636a762d/RuriLib/Blocks/BlockFunction.cs#L1057
@Ruri before posting here I always check in OB source. I was unable to find the SplitInChunks.
Thanks for your help and one more question first I have to find the string length?
@King_Kong if you use the 2nd version you're good for all possible string lengths
@Ruri That's great can't wait to use it