---
title: "Dekoda UTF8"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/180308-dekoda-utf8"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "l-boy"
published: "2009-09-17T07:00:27.000Z"
updated: "2009-09-17T07:00:27.000Z"
replies: 0
views: 291
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/180308-dekoda-utf8"
---

# Dekoda UTF8

## #1 — l-boy, 2009-09-17T07:00Z

Hittade följande funktion för att dekoda UTF8.

```
function DecodeUTF8(s)
  dim i
  dim c
  dim n

  i = 1
  do while i <= len(s)
    c = asc(mid(s,i,1))
    if c and &H80 then
      n = 1
      do while i + n < len(s)
        if (asc(mid(s,i+n,1)) and &HC0) <> &H80 then
          exit do
        end if
        n = n + 1
      loop
      if n = 2 and ((c and &HE0) = &HC0) then
        c = asc(mid(s,i+1,1)) + &H40 * (c and &H01)
      else
        c = 191 
      end if
      s = left(s,i-1) + chr(c) + mid(s,i+n)
    end if
    i = i + 1
  loop
  DecodeUTF8 = s 
end function
```

Svenska tecken i form av "åäöÅÄ" fungerar fint, men "Ö" returneras som ¿¿
Hur kan man rätta till det tro?

Permalänk: https://www.webforum.nu/p/180308

---

Tråden på webben: https://www.webforum.nu/amne/asp/180308-dekoda-utf8
