I am using .NET and I need to truncate a string that may contain multibyte characters so that it does not exceed a given length after encoding the URL. This is similar to what will be built in, but I cannot find it.
I would just execute the substring after the URL is encoded, but this could take away part of the encoded character (the space becomes% 20, and if it were at the end, it could be truncated to% 2, which is invalid), or that part a multibyte character will be truncated (π gets the encoding as% CF% 80, and it can be truncated as%,% CF,% CF% 8, all of which are erroneous).
source
share