0

The file object in Java is not supporting the character en-dash '–' (unicode \u2013). It is automatically converting the en-dash character to hyphen '-' (unicode \u002D).

I am using the ScmProvider.list method:

ListScmResult list(ScmRepository repository, ScmFileSet fileSet, 
                      boolean recursive, ScmVersion version) 

List each element (files and directories) of fileSet as they exist in the repository.

In File set, one of the items (SCM File) has the repo item with en-dash replaced with normal hyphen.

I am using Java version 1.6. Is there any limitation regarding this?

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
Harshdip Singh
  • 131
  • 1
  • 2
  • 15
  • 1
    After some Googling, I believe you are using [this method](http://maven.apache.org/scm/apidocs/org/apache/maven/scm/provider/ScmProvider.html#list%28org.apache.maven.scm.repository.ScmRepository,%20org.apache.maven.scm.ScmFileSet,%20boolean,%20org.apache.maven.scm.ScmVersion%29). Is your question specifically related to how this method works? – Duncan Jones Oct 17 '12 at 12:19
  • 1
    I think this is one of the cases where including something as a tag is not enough; you need to actually mention CollabNet, SVN, etc. in your question. And you should link to the docs, rather than just quoting them. – ruakh Oct 17 '12 at 12:29
  • Yes I would like to know how this method is working. – Harshdip Singh Oct 17 '12 at 12:32
  • @ruakh - In SVN, en-dash works fine. However, the list method is getting the array list with the items after converting the en-dash to hyphen. – Harshdip Singh Oct 17 '12 at 12:34

1 Answers1

1

Do you mean that you think that java.io.File automatically translates the character \u2013 to a regular hyphen (code \u002D)? That's not true, at least not on my Windows 7 machine running Oracle Java 6 update 35.

I tried the following code. It creates two files, with different file names; one with the long dash, one with the regular dash.

new File("C:\\Temp\\Hello\u2013World").createNewFile();
new File("C:\\Temp\\Hello-World").createNewFile();

So, whatever you see happening is not caused by some automatic conversion or limitation in java.io.File.

Jesper
  • 202,709
  • 46
  • 318
  • 350
  • The API used which is mentioned in the reply by Mr. Duncan Jones above is getting the array list of files. One of the file name has the en-dash replaced with hyphen. Not sure why! – Harshdip Singh Oct 17 '12 at 12:39