I’m trying to import from a Vanilla forum using the instructions posted here. However, I get the following error when I run the vanilla.rb import script:
Loading existing groups...
Loading existing users...
Loading existing categories...
Loading existing posts...
Loading existing topics...
parsing file...
reading file...
Traceback (most recent call last):
5: from script/import_scripts/vanilla.rb:254:in `<main>'
4: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'
3: from script/import_scripts/vanilla.rb:17:in `execute'
2: from script/import_scripts/vanilla.rb:37:in `parse_file'
1: from script/import_scripts/vanilla.rb:72:in `read_file'
script/import_scripts/vanilla.rb:72:in `gsub': invalid byte sequence in UTF-8 (ArgumentError)
I’ve tried changing the MySQL database character set to UTF8 following the instructions here and then re-exporting the porter file, but that didn’t resolve the issue. Any suggestions?
UTF-8 인코딩에 대해 검색해 볼 수 있습니다. 테이블을 UTF-8로 강제 변환하는 do something이 필요합니다. 제가 그 작업을 수행했을 때는 일부 행은 한 형식, 다른 행은 또 다른 형식으로 저장되어 있어 더 복잡한 문제가 있었습니다. 값별로 강제 변환하는 다소 어이없는 작업을 수행했던 것 같습니다.
아니, 정말 끔찍하군요. 1년 전에 한 번 해본 기억이 희미할 뿐이라, 가장 좋은 방법은 모든 데이터(또는 대부분)에 적용되는 변환 방식을 찾을 때까지 다양한 변환을 시도해 보는 것입니다. 저는 하나씩 변환을 여러 번 시도하다가 결국 모든(대부분의?) 데이터에 적용되는 변환 방식을 발견했을 때, 그 전까지의 노력이 시간 낭비였다는 것을 깨달았습니다.
아래는 제가 했던 방법입니다. 사용은 본인의 책임 하에 해주시기 바랍니다. (참고로 이 경우 vBulletin이었습니다.)
def char_map(raw_original)
raw = raw_original.dup
debug = false # (raw.length > 50)
# windows 1252
all = ''
win_encoded = ''
### WIN1252 인코딩
win_encoded = ''
begin
win_encoded = raw.force_encoding('utf-8').encode("Windows-1252",
invalid: :replace, undef: :replace, replace: ""
).force_encoding('utf-8').scrub
rescue => e
puts "\n#{'-'*50}\nWin1252 failed for \n\n#{raw}\n\n"
win_encoded = ''
end
### ISO 8859 인코딩
iso_encoded = ''
if all.length == 0 && win_encoded.length > 0 && win_encoded != raw
all = (debug ? "Win1252--" : '') + win_encoded
else
all = raw
end
all = old_char_map(all)
all
end
저도 몇 달 전 이 과정을 직접 거쳤는데(저는 개발자가 아닙니다), 셀프호스팅된 Vanilla 포럼을 셀프호스팅된 Discourse로 성공적으로 마이그레이션했습니다. 저에게 가장 중요했던 점은 Vanilla Porter를 사용해 데이터를 내보낼 때, 첫 번째 드롭다운 메뉴에서 Source Forum Type(소스 포럼 유형)으로 "Vanilla 2"를 선택하는 것이었습니다.