Detect a coding system for the text between FROM and TO with LANG-ENV. The detection takes into account the coding system priorities for the language environment LANG-ENV.