# Warning: variable $KCODE is no longer effective

**URL:** <https://www.ruby-forum.com/t/warning-variable-kcode-is-no-longer-effective/122963>\
**Category:** Ruby\
**Created:** [December 13, 2007, 1:23am UTC](https://www.ruby-forum.com/t/warning-variable-kcode-is-no-longer-effective/122963 "2007-12-13T01:23:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![miracleofmagick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71c47a/32.png) [@miracleofmagick](https://www.ruby-forum.com/u/miracleofmagick)\
**Post date:** [December 13, 2007, 1:23am UTC](https://www.ruby-forum.com/t/warning-variable-kcode-is-no-longer-effective/122963/1 "2007-12-13T01:23:32Z")

</div>

This warning comes from accessing $KCODE. What should be used instead?

In particular, this snippet from RDoc:

> @charset = case $KCODE  
> when /^S/i  
> ‘Shift\_JIS’  
> when /^E/i  
> ‘EUC-JP’  
> else  
> ‘iso-8859-1’  
> end

Eventually @charset is placed in a in the output  
RDoc. Is there a better way to determine the charset of a file?
