dev_forum
SylorHuang 5 years ago
parent 148ac868e7
commit 4e435cca0f

@ -9,17 +9,17 @@ module GitHelper
# 版本库文件内容,带转码
def git_fle_content(repo_path, path)
begin
logger.info("git file content: repo_path is #{repo_path}, path is #{path}")
Rails.logger.info("git file content: repo_path is #{repo_path}, path is #{path}")
content = GitService.file_content(repo_path: repo_path, path: path)
logger.info("git file content: content is #{content}")
Rails.logger.info("git file content: content is #{content}")
decode_content = nil
if content.present?
content = content["content"] #6.24 -hs 这个为新增,因为当实训题里含有选择题时,这里会报错,undefined method `[]' for nil:NilClass
content = Base64.decode64(content)
cd = CharDet.detect(content)
logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
Rails.logger.info "encoding: #{cd['encoding']} confidence: #{cd['confidence']}"
decode_content =
if cd["encoding"] == 'GB18030' && cd['confidence'] > 0.8

Loading…
Cancel
Save