cancel
Showing results for 
Search instead for 
Did you mean: 

replacing hebrew filename by english or numeric filename

Former Member
0 Kudos

Hi,all

I need to replace the hebrew filename by english or numeric filename

befor I upload it to KM,couse I have problem with hebrew filename

when I'm trying to open it from the portal.How can I do such replacement,i.e.

first of all I how can I know that the filename is in hebrew?

Regards,

Michael

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Michael,

First part is simple.

Check http://unicode.org/charts/PDF/U0590.pdf

Hebrew Unicode range is 0x0590 -- 0x05FF.

So you may check chars in string to see whether or not they are from Hebrew (just compare Character.getNumericValue(char ch) with range of integers above).

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Thanks for your reply,Valery

I didn't understand how exactly I check chars.

Let's say I give the file name by:

wdContext.currentContextElement().getFilePath();

What is my next step?

Regards,

Michael

Former Member
0 Kudos

Michael,

Code that detect existence of Hebrew chars could be like this:


final String path = wdContext.currentContextElement().getFilePath();
boolean hasHebrewChars = false;
for (int i = 0, size = path.length(); i < size; i++) {
  final char ch = path.charAt(i);
  if ( ch >= 0x0590 && ch <= 0x05FF) {
    hasHebrewChars = true;
    break;
  }
}

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Thanks,Valery

Now it's absolutely clear.

And now,when I know that I'm working with hebrew file name

I replace it by random number+source file extension.

Can you suggest more elegant solution?

Regards,

Michael

Former Member
0 Kudos

Michael,

Any solutions is good if it works for you

What is your definition of "more elegant"? I can guess only 2 possibilities:

-- replace only Hebrew (or any non-ASCII) characters but not English characters if any.

-- escape characters rather then replace them, so it is possible to recover original name later; however this will increase length of string, so it's easy to hit limits of max. alowed length for string, also this will require escaping of escape character and will affect names of all files.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Answers (0)