refactor : changed name to encodeAttributes() to keep shorter