Skip to content

Commit ba62bf0

Browse files
committed
[Modify] Add it
1 parent 3989809 commit ba62bf0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

websocket-sharp/Net/HttpUtility.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,40 @@ private static bool notEncoded (char c)
464464
c == '_';
465465
}
466466

467+
private static void urlEncode (byte b, Stream output)
468+
{
469+
if (b > 31 && b < 127) {
470+
if (b == 32) {
471+
output.WriteByte ((byte) '+');
472+
return;
473+
}
474+
475+
if (isNumeric (b)) {
476+
output.WriteByte (b);
477+
return;
478+
}
479+
480+
if (isAlphabet (b)) {
481+
output.WriteByte (b);
482+
return;
483+
}
484+
485+
if (isUnreserved (b)) {
486+
output.WriteByte (b);
487+
return;
488+
}
489+
}
490+
491+
output.WriteByte ((byte) '%');
492+
493+
var i = (int) b;
494+
var idx = i >> 4;
495+
output.WriteByte ((byte) _hexChars[idx]);
496+
497+
idx = i & 0x0F;
498+
output.WriteByte ((byte) _hexChars[idx]);
499+
}
500+
467501
private static void urlEncode (char c, Stream result, bool unicode)
468502
{
469503
if (c > 255) {

0 commit comments

Comments
 (0)