Skip to content

Commit

Permalink
Default to UTF-8 charset
Browse files Browse the repository at this point in the history
  • Loading branch information
tomxor committed Jun 1, 2015
1 parent 7c2f095 commit 17f2727
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/contentful/java/cda/BaseModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import retrofit.client.Response;
import rx.Observable;

import static com.contentful.java.cda.Constants.DEFAULT_CHARSET;
import static com.contentful.java.cda.RxExtensions.DefFunc;
import static com.contentful.java.cda.RxExtensions.defer;
import static com.contentful.java.cda.RxExtensions.subscribe;
Expand Down Expand Up @@ -88,7 +89,8 @@ public T fetchOne(String identifier) {
context.service.fetchResource(context.spaceId, getResourcePath(), identifier);

try {
return prepare(createCdaResource(new InputStreamReader(response.getBody().in())));
return prepare(createCdaResource(new InputStreamReader(response.getBody().in(),
DEFAULT_CHARSET)));
} catch (Exception e) {
throw RetrofitError.unexpectedError(response.getUrl(), e);
}
Expand All @@ -101,10 +103,10 @@ CDAArray fetchArray(String type, Map<String, String> query) {

try {
CDAArray array =
context.gson.fromJson(new InputStreamReader(response.getBody().in()), CDAArray.class);
context.gson.fromJson(new InputStreamReader(response.getBody().in(), DEFAULT_CHARSET),
CDAArray.class);

array.setOriginalUrl(response.getUrl());

return prepare(new ArrayParser<CDAArray>(array, context).call());
} catch (Exception e) {
throw RetrofitError.unexpectedError(response.getUrl(), e);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/contentful/java/cda/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public enum CDAFieldType {
// Configuration
public static final String ENDPOINT_CDA = "cdn.contentful.com";
public static final String ENDPOINT_PREVIEW = "preview.contentful.com";
public static final String DEFAULT_CHARSET = "UTF-8";
public static final String DEFAULT_LOCALE = "en-US";

// Resource types
Expand Down

0 comments on commit 17f2727

Please sign in to comment.