filenames

Shell script issue with filenames containing spaces

五迷三道 提交于 2019-12-01 20:36:44
问题 I understand that one technique for dealing with spaces in filenames is to enclose the file name with single quotes: "'". Why is it that the following code called, "echo.sh" works on a directory containing filenames with spaces, but the program "ls.sh" does Not work, where the only difference is 'echo' replaced with 'ls'? echo.sh #!/bin/sh for f in * do echo "'$f'" done Produces : 'a b c' 'd e f' 'echo.sh' 'ls.sh' But, "ls.sh" fails: #!/bin/sh for f in * do ls "'$f'" done Produces : ls:

How do I get the filename without the params?

北战南征 提交于 2019-12-01 17:46:43
问题 I need to find the file name of the file I've included without the GET parameters. e.g.: if the current URL is http://www.mysite.com/folder/file.php?a=b&c=d , i want file.php returned what I have found: basename($_SERVER['REQUEST_URI']) which returns: file.php?a=b&c=d in my case: I'm using the filename in a form in the section for my cart, so at the moment each time you click the 'reduce number of product' button it adds the GET params of the form (productId and action) to the end of the URL:

Windows Codepage Interactions with Standard C/C++ filenames?

こ雲淡風輕ζ 提交于 2019-12-01 17:37:18
问题 A customer is complaining that our code used to write files with Japanese characters in the filename but no longer works in all cases. We have always just used good old char * strings to represent filenames, so it came as a bit of a shock to me that it ever worked, and we haven't done anything I am aware of that should have made it stop working. I had them send me a file with an embedded filename in it exported from our software, and it looks like the strings use hex characters 82 and 83 as

Primefaces fileDownload non-english file names corrupt

烂漫一生 提交于 2019-12-01 17:19:16
I am using Primefaces 3.2. I've got problems with using primefaces fileDownload. I can upload the files and keep their non-english name on the server (in my case this is Russian). However, when I use p:fileDownload to download the uploaded files I cannot use Russian letters since they get corrupt. It seems that the DefaultStreamedContent class constructor accepts only Latin letters. I am doing everything according to the showcase on the primefaces website as shown below. public FileDownloadController() { InputStream stream = ((ServletContext)FacesContext.getCurrentInstance().getExternalContext

Primefaces fileDownload non-english file names corrupt

前提是你 提交于 2019-12-01 17:08:52
问题 I am using Primefaces 3.2. I've got problems with using primefaces fileDownload. I can upload the files and keep their non-english name on the server (in my case this is Russian). However, when I use p:fileDownload to download the uploaded files I cannot use Russian letters since they get corrupt. It seems that the DefaultStreamedContent class constructor accepts only Latin letters. I am doing everything according to the showcase on the primefaces website as shown below. public

Bash: Expand braces and globs with spaces in filenames?

℡╲_俬逩灬. 提交于 2019-12-01 16:35:01
I have some files that look like: /path/with spaces/{a,b,c}/*.gz And I need all files matching the glob under a subset of the a,b,c dirs to end up as arguments to a single command: mycmd '/path/with spaces/a/1.gz' '/path/with spaces/a/2.gz' '/path/with spaces/c/3.gz' ... The directories I care about come in as command line params and I have them in an array: dirs=( "$@" ) And I want to do something like: IFS=, mycmd "/path/with spaces/{${dirs[*]}}/"*.gz but this doesn't work, because bash expands braces before variables. I have tried tricks with echo and ls and even eval (*shudder*) but it's

Windows batch: Unicode parameters for (robo) copy command

♀尐吖头ヾ 提交于 2019-12-01 16:01:22
I need to copy multiple files in a single batch file. The files have Unicode names that map to different codepages. Example: set ArabicFile=ڊڌڵڲڛشس set CyrillicFile=щЖЛдЉи set GermanFile=Bücher copy %ArabicFile% SomePlaceElse copy %CyrillicFile% SomePlaceElse copy %GermanFile% SomePlaceElse Problem: Batch files cannot be Unicode. Question: How can I write the Unicode file names to the batch file so that the copy command recognizes them? Notes: I do not care how the file names are displayed. Actually the batch file does much more than just copy these files, I just simplified the description to

Windows batch: Unicode parameters for (robo) copy command

时间秒杀一切 提交于 2019-12-01 14:58:47
问题 I need to copy multiple files in a single batch file. The files have Unicode names that map to different codepages. Example: set ArabicFile=ڊڌڵڲڛشس set CyrillicFile=щЖЛдЉи set GermanFile=Bücher copy %ArabicFile% SomePlaceElse copy %CyrillicFile% SomePlaceElse copy %GermanFile% SomePlaceElse Problem: Batch files cannot be Unicode. Question: How can I write the Unicode file names to the batch file so that the copy command recognizes them? Notes: I do not care how the file names are displayed.

Python: Compactly and reversibly encode large integer as base64 or base16 having variable or fixed length

孤街醉人 提交于 2019-12-01 13:34:20
问题 I want to compactly encode a large unsigned or signed integer having an arbitrary number of bits into a base64, base32, or base16 (hexadecimal) representation. The output will ultimately be used as a string which will be used as a filename, but this should be beside the point. I am using the latest Python 3. This works but is far from compact: >>> import base64, sys >>> i: int = 2**62 - 3 # Can be signed or unsigned. >>> b64: bytes = base64.b64encode(str(i).encode()) # Not a compact encoding.

With a utf8-encoded Perl script, can it open a filename encoded as GB2312?

淺唱寂寞╮ 提交于 2019-12-01 13:29:26
I'm not talking about reading in the file content in utf-8 or non-utf-8 encoding and stuff. It's about file names. Usually I save my Perl script in the system default encoding, "GB2312" in my case and I won't have any file open problems. But for processing purposes, I'm now having some Perl script files saved in utf-8 encoding. The problem is: these scripts cannot open the files whose names consist of characters encoded in "GB2312" encoding and I don't like the idea of having to rename my files. Does anyone happen to have any experience in dealing with this kind of situation? Thanks like