Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:53:16+00:00 2026-06-09T00:53:16+00:00

My website allows its users to upload a file on a remote server. To

  • 0

My website allows its users to upload a file on a remote server. To avoid trouble with filenames on the server, I want to apply a simple rule to name the uploaded files on the server:

  1. replace all accented letters (à, é, è etc.) by their unaccented equivalent (ie a, e, e in our example)
  2. replace all special characters by a underscore
  3. lowercase the whole thing

My code looks like

protected String serverFilename(String localFilename) {
    if (localFilename == null || localFilename.length() == 0) {
        throw new IllegalArgumentException("Invalid filename for upload (localFilename=" + localFilename + ")");
    }

    String result = Normalizer.normalize(localFilename, Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "").replaceAll("[^a-zA-Z0-9.]", "_").toLowerCase();
    LOG.debug("filename " + localFilename + " returns: " + result);
    return result;
}

This unit test runs just fine:

assertEquals("capture_d_ecran_2012_08_02_a_12.45.29.png", uploader.serverFilename("Capture d’écran 2012-08-02 à 12.45.29.png"));

But in real action, ie in Tomcat 6 running locally on a Mac Server, when a file with a similar filename, I get a filename called ‘capture_d_ao__cran_2012_07_10____10.22.01.png’:

filename Capture d’écran 2012-07-10 à 10.22.01.png returns: capture_d_ao__cran_2012_07_10____10.22.01.png

I guess there’s some sort of mis-encoding somewhere but I don’t have any idea where.
Any tips on how i can fix this?

UPDATE: both the Java source file and the HTML responsible for uploading the file are UTF-8 encoded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:53:19+00:00Added an answer on June 9, 2026 at 12:53 am

    I’m guessing that the Java source files are saved with a different encoding (the default on Macs tends to be MacRoman, but you should always use UTF-8 everywhere) than the HTTP request encoding.

    Copypasta’d at OP’s request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to detect if remote website allows to stand under iframe or not.
I'm having trouble using PHP to SFTP upload files to a remote server. When
I built a simple website which allows users to post their profiles, classifieds and
I have a website which allows secure (ssl) file uploads and download. The site
I have a website that allows a user to upload a spreadsheet of items
I am interested in building a website that allows users to be fully anonymous.
I have a simple question and answer section on my website that allows comments.
I am developing a feature for my social networking website that allows users to
My website has a sponsorship system that allows users to invite friends by email
I have a CMS website written in aspx 2.0 that allows users to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.