[Seaside] Downloads and filenames with diacritics

Boris Popov, DeepCove Labs boris at deepcovelabs.com
Tue Sep 28 17:17:17 UTC 2010


To ensure you preserve characters, you need to go via the proper utf8 encoder when going from characters to bytes and vice versa.

-Boris (via BlackBerry)

________________________________

From: seaside-bounces at lists.squeakfoundation.org <seaside-bounces at lists.squeakfoundation.org> 
To: Seaside - general discussion <seaside at lists.squeakfoundation.org> 
Sent: Tue Sep 28 10:16:26 2010
Subject: Re: [Seaside] Downloads and filenames with diacritics 


Yeah, that is sexy.

It also needs it's complement:

String class>>fromHex: anHexString
"It returns the string that has its characters encoded in hex.
'el ñandú' asHex 
String fromHex: '656C20F1616E64FA'.
Play with those."

^ String streamContents: [:stream| |source|
source := anHexString readStream.
[source atEnd] whileFalse: [
stream nextPut: (Character value: (Integer readFrom: (source next: 2) radix: 16))]].

 sebastian



On Sep 28, 2010, at 1:50 PM, Boris Popov, DeepCove Labs wrote:


	Have you tried hexing the bytes and using that as a filename?
	
	(aString asByteArrayEncoding: #utf8) asHexString
	
	-Boris (via BlackBerry)
	
	----- Original Message -----
	From: seaside-bounces at lists.squeakfoundation.org <seaside-bounces at lists.squeakfoundation.org>
	To: Seaside - general discussion <seaside at lists.squeakfoundation.org>
	Sent: Tue Sep 28 09:24:26 2010
	Subject: Re: [Seaside] Downloads and filenames with diacritics
	
	Yeah, we actually saw that possibility but I was hoping to make the app not to be forced to maintain the original name in the database (so it can't never be confused about it nor inject maintenance costs).
	
	What do you guys think about some other way to encode the filename that preserves the original (with diacritics) but for the OS (and xsendfile) it can look like a non-diacritical one?
	
	any ideas? (or encoders to suggest?)
	
	sebastian
	
	
	
	On Sep 28, 2010, at 1:11 PM, Miguel Cobá wrote:
	
	> El mar, 28-09-2010 a las 13:03 -0300, Sebastian Sastre escribió:
	>> Hi guys,
	>>
	>> I've been using this:
	>>
	>> (GRCodec forEncoding: 'utf-8') encode: aFilaname
	>>
	>> just before writing an uploaded file (that probably has diacritics in its name).
	>>
	>> The thing is that xsendfile doesn't find the ones with diacritics and the download fails. Non diacritical downloads works just fine.
	>>
	>> As workaround I'm forcing filenames to be non-diacritical while we find a solution.
	>>
	>> Wonder if any of you guys have solved making your webapp to offer files download even when the filenames has diacriticals? I mean with xsendfile (from a seaside app of course).
	>
	> Store the files with numbers and save the original name in the database.
	> Xsendfile the numbered file and state that the file should be offered
	> with the original name. For example, in PHP:
	>
	>    header("X-Sendfile: $numberedfile");
	>    header("Content-Type: application/octet-stream");
	>    header("Content-Disposition: attachment; file=\"$originalname\"");
	>
	> The downloaded file needs not to be the same name that the save as
	> offered by the browser.
	>
	> Cheers
	>
	>>
	>> sebastian_______________________________________________
	>> seaside mailing list
	>> seaside at lists.squeakfoundation.org
	>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
	>
	> --
	> Miguel Cobá
	> http://miguel.leugim.com.mx <http://miguel.leugim.com.mx/> 
	>
	> _______________________________________________
	> seaside mailing list
	> seaside at lists.squeakfoundation.org
	> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
	
	_______________________________________________
	seaside mailing list
	seaside at lists.squeakfoundation.org
	http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
	

	_______________________________________________
	seaside mailing list
	seaside at lists.squeakfoundation.org
	http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
	


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20100928/a1ab4ef9/attachment-0001.htm


More information about the seaside mailing list