c# - Encode header value using WebClient.Headers.Add() -
i using http headers send string contains unicode characters (such ñ
) custom http server.
when add string header:
webclient.headers.add("custom-data", "señor");
it interpreted server as:
se�or
obviously need encode value differently, unsure encoding use.
how should encode http header preserve extended/special characters?
- pornel's answer related question confusing.
- unanswered, related: c# webclient non-english request header value encoding
as @jordan suggested, representing string base64 (with utf8 encoding) worked well:
on client side:
webclient.headers.add("custom-data", convert.tobase64string(encoding.utf8.getbytes("señor")));
and on server:
string customdata = encoding.utf8.getstring(convert.frombase64string(customheader.value));
Comments
Post a Comment