[Mulgara-dev] why line separator into base64 string?
Robert Turner
rturner at herzumsoftware.com
Mon Aug 20 13:07:08 UTC 2007
Hi Robert,
According to the W3C XSD Base64Binary spec, lines should be limited to
76 characters in length:
"For compatibility with older mail gateways, [RFC 2045] <http://www.w3.org/TR/xmlschema-2/#RFC2045> suggests that
base64 data should have lines limited to at most 76 characters in length."
(http://www.w3.org/TR/xmlschema-2/#base64Binary) <http://www.w3.org/TR/xmlschema-2/#base64Binary>
In case it needs changing, the code that enforces this is on line 255
of:
<mulgara-root>/src/jar/store-stringpool/java/org/mulgara/store/stringpool/xa/SPBase64BinaryImpl.java
Cheers,
Rob Turner
Roberto Sidoti wrote:
> Hi all,
> I have this little problem using base64
> (<http://www.w3.org/2001/XMLSchema#base64Binary>) data:
> When I have to convert an Answer field into string it is not a valid base64
> string:
>
> public String asBase64String(Answer a) {
> String prop=null;
> String obj=null;
> boolean empty=true;
> if(a.next()){
> empty=false;
> prop=a.getObject(0).toString();
> if(prop.equals(BASEURL+"blobContent")){
> obj=a.getObject(1).toString();
> obj=obj.replaceAll(System.getProperty("line.separator"),
> "");
> int ind=obj.lastIndexOf("^^");
> obj=obj.substring(0,ind);
> obj=obj.substring(1,obj.length()-1);//escape \" at start and
> end of string
> }
> }
> if(empty)
> return null;
> else
> return obj;
> }
>
> In order to get a valid base64 string I used
>
> obj=obj.replaceAll(System.getProperty("line.separator"), "");
>
> because every 77 characters there is a System.getProperty("line.separator")
> String. I discovered this thing looking into
> org.mulgara.store.stringpool.xa.SPBase64BinaryImpl
> getLexicalForm method (I thing this is the matter...).
>
> Why did you put a "line.separator" every 77 chars?
> There is another way to get a valid base64 string from an Answer object?
>
> Regards
> roby
>
> _______________________________________________
> Mulgara-dev mailing list
> Mulgara-dev at mulgara.org
> http://mulgara.org/mailman/listinfo/mulgara-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mulgara.org/pipermail/mulgara-dev/attachments/20070820/7ebd6674/attachment.htm>
More information about the Mulgara-dev
mailing list