Method and apparatus for line coding