Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/EncodingHelper.java @ 320:678e326fd27c
Issue 15: Exception accessing oddly named file from history
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 30 Sep 2011 06:22:11 +0200 |
parents | |
children | ac38e75c9e8e |
comparison
equal
deleted
inserted
replaced
319:fa4aea41746e | 320:678e326fd27c |
---|---|
1 /* | |
2 * Copyright (c) 2011 TMate Software Ltd | |
3 * | |
4 * This program is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; version 2 of the License. | |
7 * | |
8 * This program is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * For information on how to redistribute this software under | |
14 * the terms of a license other than GNU General Public License | |
15 * contact TMate Software at support@hg4j.com | |
16 */ | |
17 package org.tmatesoft.hg.internal; | |
18 | |
19 import java.io.UnsupportedEncodingException; | |
20 import java.nio.charset.Charset; | |
21 | |
22 import org.tmatesoft.hg.core.HgBadStateException; | |
23 | |
24 /** | |
25 * Keep all encoding-related issues in the single place | |
26 * @author Artem Tikhomirov | |
27 * @author TMate Software Ltd. | |
28 */ | |
29 public class EncodingHelper { | |
30 // XXX perhaps, shall not be full of statics, but rather an instance coming from e.g. HgRepository? | |
31 | |
32 public static String fromManifest(byte[] data, int start, int length) { | |
33 try { | |
34 return new String(data, start, length, "ISO-8859-1"); | |
35 } catch (UnsupportedEncodingException ex) { | |
36 // can't happen | |
37 throw new HgBadStateException(ex); | |
38 } | |
39 } | |
40 } |