Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of git@github.com:henon/GitSharp
  • Loading branch information
henon committed Sep 28, 2009
2 parents d820e32 + 82a51c8 commit af2df74
Showing 1 changed file with 36 additions and 26 deletions.
62 changes: 36 additions & 26 deletions Core/Util/RawParseUtils.cs
Expand Up @@ -917,32 +917,42 @@ public static string decodeNoFallback(Encoding cs, byte[] buffer, int start, int
b[i] = buffer[start + i];


if (cs != null)
{
// Try the suggested encoding, it might be right since it was
// provided by the caller.
//
try
{
return decode(b, cs);
}
catch (DecoderFallbackException)
{
//b.reset();
}
}
// No encoding specified or decoding failed, try default charset
//
try
{
return decode(b, Constants.CHARSET);
}
catch (DecoderFallbackException)
{
//b.reset();
}

throw new DecoderFallbackException("decoding failed with encoding: " + cs.HeaderName);
// Try our built-in favorite. The assumption here is that
// decoding will fail if the data is not actually encoded
// using that encoder.
//
try {
return decode(b, Constants.CHARSET);
} catch (DecoderFallbackException e) {
//b.reset();
}

if (!cs.Equals(Constants.CHARSET)) {
// Try the suggested encoding, it might be right since it was
// provided by the caller.
//
try {
return decode(b, cs);
} catch (DecoderFallbackException e) {
//b.reset();
}
}

// Try the default character set. A small group of people
// might actually use the same (or very similar) locale.
//
Encoding defcs = Encoding.Default;
if (!defcs.Equals(cs) && !defcs.Equals(Constants.CHARSET)) {
try {
return decode(b, defcs);
}
catch (DecoderFallbackException e)
{
//b.reset();
}
}

throw new DecoderFallbackException(string.Format("Unable to decode provided buffer using encoder '{0}'.", cs.WebName) );
}

/**
Expand Down

0 comments on commit af2df74

Please sign in to comment.