Skip to content

Commit

Permalink
Fix the way encoding information in SPSS is handled.
Browse files Browse the repository at this point in the history
  • Loading branch information
melff committed May 24, 2021
1 parent 9f39209 commit c74e620
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: memisc
Type: Package
Title: Management of Survey Data and Presentation of Analysis Results
Version: 0.99.30
Date: 2021-05-03
Version: 0.99.30.1
Date: 2021-05-24
Author: Martin Elff (with contributions from Christopher N. Lawrence, Dave Atkins, Jason W. Morgan, Achim Zeileis)
Maintainer: Martin Elff <[email protected]>
Description: An infrastructure for the management of survey data including
Expand Down
20 changes: 15 additions & 5 deletions pkg/R/spss-sysfile-methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ spss.system.file <- function(

if(length(aux$aux_enc)){
encoding2 <- toupper(aux$aux_enc)
if(encoding2 %in% iconvlist())
if(encoding2 %in% iconvlist()){
encoding <- encoding2
message(sprintf("File character set is '%s'.",encoding))
message(sprintf("File character set is '%s'.",encoding))
}
else {
warning(sprintf("File contains unsupported character set '%s', using fallback.",encoding2))
encoding <- encoded
}
}
else if(length(aux$info_int32)){
encoding <- aux$info_int32["character_code"]
Expand All @@ -133,13 +138,18 @@ spss.system.file <- function(
"ISO8859-1"=28591,
"UTF-8"=65001)
encoding1 <- names(enc_table)[match(encoding,enc_table)]
if(encoding1 %in% iconvlist())
if(encoding1 %in% iconvlist()){
encoding <- encoding1
message(sprintf("File character set is '%s'.",encoding))
message(sprintf("File character set is '%s'.",encoding))
}
else {
warning(sprintf("File contains unsupported character set '%s', using fallback.",encoding1))
encoding <- encoded
}
}
else {
encoding <- encoded
message("File does not contain character set encoding information, using fallback")
message("File does not contain character set encoding information, using fallback.")
}

if(iconv){
Expand Down
3 changes: 3 additions & 0 deletions pkg/inst/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2021-05-24:
- Fixed use of file-supplied encoding information.

2021-05-03:
- Fixed handling of missing values (NA) in 'cases()'.

Expand Down

0 comments on commit c74e620

Please sign in to comment.