[R] Handle UTF-8 paths on Windows (#9448)

This commit is contained in:
Philip Hyunsu Cho
2023-08-08 21:29:19 -07:00
committed by GitHub
parent c1b2cff874
commit 819098a48f
3 changed files with 23 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ xgb.Booster.handle <- function(params = list(), cachelist = list(),
## A filename
handle <- .Call(XGBoosterCreate_R, cachelist)
modelfile <- path.expand(modelfile)
.Call(XGBoosterLoadModel_R, handle, modelfile[1])
.Call(XGBoosterLoadModel_R, handle, enc2utf8(modelfile[1]))
class(handle) <- "xgb.Booster.handle"
if (length(params) > 0) {
xgb.parameters(handle) <- params

View File

@@ -43,6 +43,6 @@ xgb.save <- function(model, fname) {
}
model <- xgb.Booster.complete(model, saveraw = FALSE)
fname <- path.expand(fname)
.Call(XGBoosterSaveModel_R, model$handle, fname[1])
.Call(XGBoosterSaveModel_R, model$handle, enc2utf8(fname[1]))
return(TRUE)
}