Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文字コードがCP932の環境でspdf中のcity_name_full以外のマルチバイト文字が文字化けする #2

Closed
yokoyamt opened this issue Dec 6, 2016 · 2 comments
Labels

Comments

@yokoyamt
Copy link

@yokoyamt yokoyamt commented Dec 6, 2016

ver0.1.0からshpファイルを必ずしもダウンロードしなくてよくなったのでめっちゃ使い勝手良くなりました。
ありがとうございます。

ところで、Win環境で使っていると表題のような問題に遭遇したので、issue立てました。
パッケージ使用者側でstringi::stri_encode()なりstringr::str_conv()なり使ってあげればいいだけかもですが、
気になったのでissue立てました。

data-raw/shp2topojson.Rのところで何か処理をかませばよさそうな気もするので、shpファイルのダウンロードができて、検証できたらまた追記します。

> library(dplyr, quietly = TRUE)
> library(jpndistrict, quietly = TRUE)
> df.city33104 <- spdf_jpn_cities(jis_code_pref = 33, jis_code = 33104)
> df.city33104 %>% 
+   dplyr::mutate(pref_name2 = stringi::stri_encode(str = pref_name, from = "UTF-8"))
class       : SpatialPolygonsDataFrame 
features    : 2 
extent      : 133.8162, 134.0472, 34.51852, 34.64384  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=GRS80 +no_defs 
variables   : 6
# A tibble: 2 × 6
     pref_name   city_name_ city_name city_name_full city_code pref_name2
         <chr>        <chr>     <chr>          <chr>    <fctr>      <chr>
1 蟯。螻ア逵\x8c 蟯。螻ア蟶\x82    蜊怜玄    岡山市 南区     33104     岡山県
2 蟯。螻ア逵\x8c 蟯。螻ア蟶\x82    蜊怜玄    岡山市 南区     33104     岡山県
> devtools::session_info()
Session info -----------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, mingw32             
 ui       RStudio (1.0.44)            
 language (EN)                        
 collate  Japanese_Japan.932          
 tz       Asia/Tokyo                  
 date     2016-12-06                  

Packages ---------------------------------------------------------------------------------------------
 package     * version    date       source                            
 animation     2.4        2015-08-16 CRAN (R 3.3.2)                    
 assertthat    0.1        2013-12-06 CRAN (R 3.3.2)                    
 colorspace    1.3-0      2016-11-10 CRAN (R 3.3.2)                    
 curl          2.2        2016-10-21 CRAN (R 3.3.2)                    
 DBI           0.5-1      2016-09-10 CRAN (R 3.3.2)                    
 devtools      1.12.0     2016-06-24 CRAN (R 3.3.2)                    
 digest        0.6.10     2016-08-02 CRAN (R 3.3.2)                    
 dplyr       * 0.5.0      2016-06-24 CRAN (R 3.3.2)                    
 foreign       0.8-67     2016-09-13 CRAN (R 3.3.2)                    
 geojsonio     0.2.0      2016-07-14 CRAN (R 3.3.2)                    
 ggghost       0.2.1      2016-08-20 CRAN (R 3.3.2)                    
 ggplot2       2.2.0      2016-11-11 CRAN (R 3.3.2)                    
 ggthemes      3.3.0      2016-11-24 CRAN (R 3.3.2)                    
 gtable        0.2.0      2016-02-26 CRAN (R 3.3.2)                    
 htmltools     0.3.5      2016-03-21 CRAN (R 3.3.2)                    
 htmlwidgets   0.8        2016-11-09 CRAN (R 3.3.2)                    
 httpuv        1.3.3      2015-08-04 CRAN (R 3.3.2)                    
 httr          1.2.1      2016-07-03 CRAN (R 3.3.2)                    
 jpndistrict * 0.1.0.9999 2016-12-05 Github (uribo/jpndistrict@26dca21)
 jsonlite      1.1        2016-09-14 CRAN (R 3.3.2)                    
 lattice       0.20-34    2016-09-06 CRAN (R 3.3.2)                    
 lazyeval      0.2.0      2016-06-12 CRAN (R 3.3.2)                    
 leaflet       1.0.1      2016-02-27 CRAN (R 3.3.2)                    
 magrittr      1.5        2014-11-22 CRAN (R 3.3.2)                    
 maptools      0.8-40     2016-11-15 CRAN (R 3.3.2)                    
 memoise       1.0.0      2016-01-29 CRAN (R 3.3.2)                    
 mime          0.5        2016-07-07 CRAN (R 3.3.2)                    
 miniUI        0.1.1      2016-01-15 CRAN (R 3.3.2)                    
 munsell       0.4.3      2016-02-13 CRAN (R 3.3.2)                    
 plyr          1.8.4      2016-06-08 CRAN (R 3.3.2)                    
 R6            2.2.0      2016-10-05 CRAN (R 3.3.2)                    
 Rcpp          0.12.7     2016-09-05 CRAN (R 3.3.2)                    
 readr         1.0.0      2016-08-03 CRAN (R 3.3.2)                    
 rgdal         1.2-4      2016-11-15 CRAN (R 3.3.2)                    
 rgeos         0.3-21     2016-10-20 CRAN (R 3.3.2)                    
 rmapshaper    0.1.0      2016-06-29 CRAN (R 3.3.2)                    
 rstudioapi    0.6        2016-06-27 CRAN (R 3.3.2)                    
 scales        0.4.1      2016-11-09 CRAN (R 3.3.2)                    
 shiny         0.14.2     2016-11-01 CRAN (R 3.3.2)                    
 sp            1.2-3      2016-04-14 CRAN (R 3.3.2)                    
 spbabel       0.4.5      2016-10-06 CRAN (R 3.3.2)                    
 spdplyr       0.1.2      2016-07-30 CRAN (R 3.3.2)                    
 stringi       1.1.2      2016-10-01 CRAN (R 3.3.2)                    
 tibble        1.2        2016-08-26 CRAN (R 3.3.2)                    
 V8            1.1        2016-07-16 CRAN (R 3.3.2)                    
 withr         1.0.2      2016-06-20 CRAN (R 3.3.2)                    
 xtable        1.8-2      2016-02-05 CRAN (R 3.3.2)                    

@uribo uribo added the bug 💣 label Dec 6, 2016
uribo added a commit that referenced this issue Dec 7, 2016
ref) #2
@uribo
Copy link
Owner

@uribo uribo commented Dec 7, 2016

報告いただきありがとうございます。

検証不足でした。
UTF8を指定してエンコードし直したので再度お試しいただけますでしょうか。

uribo added a commit that referenced this issue Dec 7, 2016
ref) #2
@yokoyamt
Copy link
Author

@yokoyamt yokoyamt commented Dec 8, 2016

最新版で再度試したら問題解決しました! ありがとうございます!!

> library(jpndistrict)
> library(dplyr)
> library(jpndistrict)
> df.city33104 <- spdf_jpn_cities(jis_code_pref = 33, jis_code = 33104)
> df.city33104
class       : SpatialPolygonsDataFrame 
features    : 2 
extent      : 133.8162, 134.0472, 34.51852, 34.64384  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=GRS80 +no_defs 
variables   : 5
# A tibble: 2 × 5
  pref_name city_name_ city_name city_name_full city_code
*     <chr>      <chr>     <chr>          <chr>    <fctr>
1    岡山県     岡山市      南区    岡山市 南区     33104
2    岡山県     岡山市      南区    岡山市 南区     33104
> devtools::session_info()
Session info ----------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, mingw32             
 ui       RStudio (1.0.44)            
 language (EN)                        
 collate  Japanese_Japan.932          
 tz       Asia/Tokyo                  
 date     2016-12-08                  

Packages --------------------------------------------------------------------------------
 package     * version    date       source                            
 animation     2.4        2015-08-16 CRAN (R 3.3.2)                    
 assertthat    0.1        2013-12-06 CRAN (R 3.3.2)                    
 colorspace    1.3-0      2016-11-10 CRAN (R 3.3.2)                    
 curl          2.2        2016-10-21 CRAN (R 3.3.2)                    
 DBI           0.5-1      2016-09-10 CRAN (R 3.3.2)                    
 devtools      1.12.0     2016-06-24 CRAN (R 3.3.2)                    
 digest        0.6.10     2016-08-02 CRAN (R 3.3.2)                    
 dplyr       * 0.5.0      2016-06-24 CRAN (R 3.3.2)                    
 foreign       0.8-67     2016-09-13 CRAN (R 3.3.2)                    
 geojsonio     0.2.0      2016-07-14 CRAN (R 3.3.2)                    
 ggghost       0.2.1      2016-08-20 CRAN (R 3.3.2)                    
 ggplot2       2.2.0      2016-11-11 CRAN (R 3.3.2)                    
 ggthemes      3.3.0      2016-11-24 CRAN (R 3.3.2)                    
 gtable        0.2.0      2016-02-26 CRAN (R 3.3.2)                    
 htmltools     0.3.5      2016-03-21 CRAN (R 3.3.2)                    
 htmlwidgets   0.8        2016-11-09 CRAN (R 3.3.2)                    
 httpuv        1.3.3      2015-08-04 CRAN (R 3.3.2)                    
 httr          1.2.1      2016-07-03 CRAN (R 3.3.2)                    
 jpndistrict * 0.1.0.9999 2016-12-08 Github (uribo/jpndistrict@ff3030a)
 jsonlite      1.1        2016-09-14 CRAN (R 3.3.2)                    
 lattice       0.20-34    2016-09-06 CRAN (R 3.3.2)                    
 lazyeval      0.2.0      2016-06-12 CRAN (R 3.3.2)                    
 leaflet       1.0.2.9009 2016-12-08 Github (rstudio/leaflet@36a9ee3)  
 magrittr      1.5        2014-11-22 CRAN (R 3.3.2)                    
 maptools      0.8-40     2016-11-15 CRAN (R 3.3.2)                    
 memoise       1.0.0      2016-01-29 CRAN (R 3.3.2)                    
 mime          0.5        2016-07-07 CRAN (R 3.3.2)                    
 miniUI        0.1.1      2016-01-15 CRAN (R 3.3.2)                    
 munsell       0.4.3      2016-02-13 CRAN (R 3.3.2)                    
 plyr          1.8.4      2016-06-08 CRAN (R 3.3.2)                    
 R6            2.2.0      2016-10-05 CRAN (R 3.3.2)                    
 Rcpp          0.12.7     2016-09-05 CRAN (R 3.3.2)                    
 readr         1.0.0      2016-08-03 CRAN (R 3.3.2)                    
 rgdal         1.2-4      2016-11-15 CRAN (R 3.3.2)                    
 rgeos         0.3-21     2016-10-20 CRAN (R 3.3.2)                    
 rmapshaper    0.1.0      2016-06-29 CRAN (R 3.3.2)                    
 scales        0.4.1      2016-11-09 CRAN (R 3.3.2)                    
 shiny         0.14.2     2016-11-01 CRAN (R 3.3.2)                    
 sp            1.2-3      2016-04-14 CRAN (R 3.3.2)                    
 spbabel       0.4.5      2016-10-06 CRAN (R 3.3.2)                    
 spdplyr       0.1.2      2016-07-30 CRAN (R 3.3.2)                    
 stringi       1.1.2      2016-10-01 CRAN (R 3.3.2)                    
 tibble        1.2        2016-08-26 CRAN (R 3.3.2)                    
 V8            1.1        2016-07-16 CRAN (R 3.3.2)                    
 withr         1.0.2      2016-06-20 CRAN (R 3.3.2)                    
 xtable        1.8-2      2016-02-05 CRAN (R 3.3.2)                    

@uribo uribo closed this Dec 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.