title: Is there a way in R to merge two raw values (bytes) in one single value to be used as input by the rawToChar()?
body: <p>While I was fetching data from a greek site (data contains also greek characters),
  I was expecting the first value to be &quot;ΚΡΗΤΗ&quot;, but instead I received the following string &quot;ÎšÎ¡Î—Î¤Î—&quot;.</p>
  <p>As I was trying to figure out the problem I tested the following:</p>
  <pre><code>charToRaw(&quot;ÎšÎ¡Î—Î¤Î—&quot;)
  [1] ce 9a ce a1 ce 97 ce a4 ce 97
  
  charToRaw(&quot;ΚΡΗΤΗ&quot;)
  [1] ce 9a ce a1 ce 97 ce a4 ce 97
  </code></pre>
  <p>which at first seemed like the same thing.
  The problem is that each of the greek character contains two bytes of information as shown below:</p>
  <pre><code>charToRaw(&quot;Κ&quot;)
  [1] ce 9a
  </code></pre>
  <p>But when I tried the opposite thing, namely to convert the two raw bytes back to character using rawToChar, I faced the following problem, where each of the two bytes is converted to a character.</p>
  <pre><code>rawToChar(as.raw(c(0xce, 0x9a)))
  [1] &quot;Îš&quot;
  </code></pre>
  <p>Therefore I tried to find if you can force the rawToChar to use 2 bytes as one value, but I couldn't find a way. This made me to write a custom function in order to achieve my goal, but unfortunately I faced a new problem.
  Using the first value of the data that was acquired from the site as input to the charToRaw, the aforementioned function gives different output from which I get if I copy the content of the value and use it as input to charToRaw. You can see that in the following snippet:</p>
  <pre><code>&gt; data$area[1]
  [1] &quot;ÎšÎ¡Î—Î¤Î—&quot;
  &gt; copiedValue = &quot;ÎšÎ¡Î—Î¤Î—&quot;
  &gt; copiedValue
  [1] &quot;ÎšÎ¡Î—Î¤Î—&quot;
  &gt; identical(data$area[1], copiedValue)
  [1] TRUE
  &gt; charToRaw(data$area[1])
  [1] c3 8e c5 a1 c3 8e c2 a1 c3 8e e2 80 94 c3 8e c2 a4 c3 8e e2 80 94
  &gt; charToRaw(copiedValue)
  [1] ce 9a ce a1 ce 97 ce a4 ce 97
  </code></pre>
  <p>Finally I tried the &quot;iconv&quot; function and a number of different encodings but neither this didn't seem to solve the problem.</p>
  <pre><code>iconv(&quot;ΚΡΗΤΗ&quot;, from = &quot;Windows-1252&quot;, to = &quot;UTF8&quot;)
  [1] &quot;ÎšÎ¡Î—Î¤Î—&quot;
  &gt; iconv(&quot;ÎšÎ¡Î—Î¤Î—&quot;, from = &quot;UTF8&quot;, to = &quot;Windows-1252&quot;)
  [1] NA
  </code></pre>