file-encodings

How to expand file content with powershell

馋奶兔 提交于 2019-12-08 04:09:12
问题 I want to do this : $content = get-content "test.html" $template = get-content "template.html" $template | out-file "out.html" where template.html contains <html> <head> </head> <body> $content </body> </html> and test.html contains: <h1>Test Expand</h1> <div>Hello</div> I get weird characters in first 2 characters of out.html : �� and content is not expanded. How to fix this ? 回答1: To complement Mathias R. Jessen's helpful answer with a solution that: is more efficient. ensures that the

How do I set file.encoding for a junit test in ant?

試著忘記壹切 提交于 2019-12-07 10:07:09
问题 I'm not quite done with file.encoding and ant. How do I set the file.encoding for junit tests in ant? The junit ant task doesn't support the encoding attribute like the javac task does. I've tried running «ant -Dfile.encoding=UTF-8» and «ANT_OPTS="-Dfile.encoding=UTF-8" ant» without success. System.getProperty("file.encoding") within a test still returns MacRoman . 回答1: JUnit supports a child element <jvmarg ...> which should do what you want. <junit fork="yes"> <jvmarg value="-Dfile.encoding

Charset of Java source file and failing test

好久不见. 提交于 2019-12-07 03:08:28
First, I'd like to say that I've spent a lot of time searching for an explanation/solution. I've found hints of the problem, but no way to resolve my particular issue. Hence the post on a topic that seems to have been beaten to death in at least some cases. I have a Java test class that tests for proper encoding/decoding by a Mime utility. The strings used for testing are declared in the source file and we use assertEquals() to test equality after processing the input string. Here's an example: String test = "S2, =?iso-8859-1?Q?F=E4ltstr=F6m?= =?iso-8859-1?Q?,_Patrik?= S3"; String expected =

Convert files encoding

北城余情 提交于 2019-12-06 07:59:28
问题 I have a PHP application who's files encoding is Greek ISO (iso-8859-7). I want to convert the files to utf-8 but simply saving the files with utf-8 isn't enough since the Greek texts get garbled. Is there an "automatic" method to do this so that I can completely convert my app's encoding without having to go through each file and rewrite the texts? 回答1: On a Linux system, if you are sure all files are currently encoded in ISO-8859-7, you can do this: bash> find /your/path -name "*.php" -type

How do I set file.encoding for a junit test in ant?

六眼飞鱼酱① 提交于 2019-12-05 16:21:42
I'm not quite done with file.encoding and ant . How do I set the file.encoding for junit tests in ant? The junit ant task doesn't support the encoding attribute like the javac task does. I've tried running «ant -Dfile.encoding=UTF-8» and «ANT_OPTS="-Dfile.encoding=UTF-8" ant» without success. System.getProperty("file.encoding") within a test still returns MacRoman . JUnit supports a child element <jvmarg ...> which should do what you want. <junit fork="yes"> <jvmarg value="-Dfile.encoding=UTF-8"/> ... </junit> I assume you were using the fork=yes attribute since this starts a new JVM for the

Convert files encoding

天大地大妈咪最大 提交于 2019-12-04 11:49:48
I have a PHP application who's files encoding is Greek ISO (iso-8859-7). I want to convert the files to utf-8 but simply saving the files with utf-8 isn't enough since the Greek texts get garbled. Is there an "automatic" method to do this so that I can completely convert my app's encoding without having to go through each file and rewrite the texts? On a Linux system, if you are sure all files are currently encoded in ISO-8859-7, you can do this: bash> find /your/path -name "*.php" -type f \ -exec iconv "{}" -f ISO88597 -t UTF8 -o "{}.tmp" \; \ -exec mv "{}.tmp" "{}" \; This converts all PHP

How can I set the default file format in the Delphi IDE to UTF8?

浪子不回头ぞ 提交于 2019-12-03 13:12:07
问题 Delphi 2009 sets the default file format for new source code files to ANSI, this makes the source code platform-dependent. Even for a new XSD file created in the IDE, which by default starts with this line <?xml version="1.0" encoding="UTF-8" ?> Delphi sets the file format to ANSI (this looks like a bug, for new XML and XSLT documents UTF8 is selected by default). Is there a hidden option to set the default file format for source code files? 回答1: AFAIK, there is no IDE-wide setting for

PowerShell out-file: prevent encoding changes

六眼飞鱼酱① 提交于 2019-11-28 19:16:19
I'm currently working on some search and replace operation that I'm trying to automate using powershell. Unfortunately I recognized yesterday that we've different file encodings in our codebase (UTF8 and ASCII). Because we're doing these search and replace operations in a different branch I can't change the file encodings at this stage. If I'm running the following lines it changes all files to UCS-2 Little Eindian even though my default powershell encoding is set to iso-8859-1 (Western European (Windows)). $content = Get-Content $_.Path $content -replace 'myOldText' , 'myNewText' | Out-File $

How can I be sure of the file encoding?

牧云@^-^@ 提交于 2019-11-27 06:30:27
I have a PHP file that I created with VIM, but I'm not sure which is its encoding. When I use the terminal and check the encoding with the command file -bi foo (My operating system is Ubuntu 11.04) it gives me the next result: text/html; charset=us-ascii But, when I open the file with gedit it says its encoding is UTF-8. Which one is correct? I want the file to be encoded in UTF-8. My guess is that there's no BOM in the file and that the command file -bi reads the file and doesn't find any UTF-8 characters, so it assumes that it's ascii, but in reality it's encoded in UTF-8. Well, first of all

File.listFiles() mangles unicode names with JDK 6 (Unicode Normalization issues)

一笑奈何 提交于 2019-11-27 03:44:09
I'm struggling with a strange file name encoding issue when listing directory contents in Java 6 on both OS X and Linux: the File.listFiles() and related methods seem to return file names in a different encoding than the rest of the system. Note that it is not merely the display of these file names that is causing me problems. I'm mainly interested in doing a comparison of file names with a remote file storage system, so I care more about the content of the name strings than the character encoding used to print output. Here is a program to demonstrate. It creates a file with a Unicode name