I'm running into a problem on a specific customer's org when attempting to get the HTML from a custom object's standard 'new' page layout.
String objPrefix = My_Object__c.SObjectType.getDescribe().getKeyPrefix();
PageReference page = new PageReference('/' + objPrefix + '/e?nooverride=1');
Blob b = page.getContent();
String html = b.toString();
Using the above code results inBLOB is not a valid UTF-8 string
when attempting to use the toString()
method.
This code is running in a managed package and has worked successfully in many other orgs.
I know that Blob.toString()
method is only supported for UTF-8 encoded strings, but shouldn't all VisualForce pages be encoded as UTF-8?