Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The code below produces an incorrect result for variables s and b. The results do not match what is produced in standard .NET.
byte b = Convert.FromBase64String("UBo3FDjs8DabAbDhVwzqqQ==");
string s = Encoding.UTF8.GetString(b) + "WQ3cgGvwGI10jSZoQQTTGsdk3nFH2xTVUvOXIV1JVM0=";
b = Encoding.UTF8.GetBytes(s);
s = Convert.ToBase64String(b);
b = Convert.FromBase64String(s);
s = UBo3FDjvv73vv70277+9Ae+/ve+/vVcM77+9V1EzY2dHdndHSTEwalNab1FRVFRHc2RrM25GSDJ4VFZVdk9YSVYxSlZNMD0=
b = 71
s = UBo3FDjvv73vv70277+9Ae+/ve+/vVcM77+977+9V1EzY2dHdndHSTEwalNab1FRVFRHc2RrM25GSDJ4VFZVdk9YSVYxSlZNMD0=
b = 74
The above code may actually be a problem with UTF8 Encoding rather than Base64 encoding. Regardless, there seems to be a problem.
This may be part of my problem, although I still wonder why it produces a different result than .NET:
"Not every byte sequence represents an Unicode string encoded in UTF-8 or UTF-16.
Not every Unicode string represents a byte sequence encoded in Base64."
Thank you for the detailed bug report.
The pull request for this issue can be found in the link below.
Fixed in master b5fcd926f8ee870e107cf534c1f9592586b8a0e9.