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?

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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -