-
Notifications
You must be signed in to change notification settings - Fork 16
Manage charset problems
When you work with Retrofit and web services, you are probably (I hope so) working with UTF-8. Just remember that JSON RFC specifies to with it. In somecase I had to manage incorrect situation without change the backend behaviour (the server produce JSON is no UTF-8).
Jackson library in its default behaviour throw an exception. To control this, since kripton 7-rc.9, it is possible to specify the error action to manage charset errors and what are the expected charset.
An example:
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://jsonplaceholder.typicode.com")
.addConverterFactory(KriptonBinderConverterFactory.Builder.create()
.setDefaultCharset(StandardCharsets.UTF_8)
.setErrorAction(CodingErrorAction.IGNORE)
.build())
.build();
With setDefaultCharset
you can specify the charset used to decode incoming stream (response body) and outcoming stream (request body). With setErrorAction
you specify how to manage unexpected char. The default value for error action is IGNORE (the wrong char is deleted, without exception).
- Introduction
- Goals & Features
- Kotlin
- Immutable or Mutable Pojo
- Annotation Processor Args
- Credits
- Articles
- Benchmarks
- Setup
- Tutorial
- Usage
- Dependencies and inspirations
- Stackoverflow
- Documentation
- SQL logging
- Data source options
- Indices
- SQL Type adapter
- Global SQL Type adapter
- Constraints
- Live data: welcome Architectural components!!
- Paged Live data
- Dynamic parts
- Transactional and batch operations
- Async Transactional and batch operations
- Global transaction
- Support for immutable POJO
- Generate Content provider
- Generate Database schema generation
- Database migration
- BindSqlColumn
- BindContentProvider
- BindContentProviderEntry
- BindContentProviderPath
- BindDao
- BindDaoMany2Many
- BindDataSource
- BindDataSourceOptions
- BindDataSourceUpdateTask
- BindIndex
- BindSqlRelation
- BindSqlAdapter
- BindSqlChildSelect
- BindSqlDelete
- BindSqlDynamicOrderBy
- BindSqlDynamicWhere
- BindSqlDynamicWhereParams
- BindSqlInsert
- BindSqlPageSize
- BindSqlParam
- BindSqlSelect
- BindSqlUpdate
- BindSqlType
- BindSqlTransaction