Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9170043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:57:44+00:00 2026-06-17T15:57:44+00:00

I am loading contents from a URL; the URL is in the form www.example.com/?keyword=something.

  • 0

I am loading contents from a URL; the URL is in the form http://www.example.com/?keyword=something. I get the specific content based on user’s keyword like this:

$url = 'www.example.com/?';
$url = $url."keyword=$something";

function getData ($url) {

    $data = file_get_contents($url);

    return $data;
}

The original data contains Scandinavian characters like Ö or Å. After loading, those characters are not any more readable. How to fix this special character problem?

UPDATE:

I changed the code this way:

function getData ($url) {

   $data = urlencode(file_get_contents($url));
   $data = urldecode($data);

    return $data;
}

Didn’t help either. Also $data = utf8_decode(urldecode($data)); and echo utf8_decode(urldecode(getData($keyword))); don’t help. What am I doing whrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:57:45+00:00Added an answer on June 17, 2026 at 3:57 pm

    file_get_contents is not charset aware. It returns the exact bytes that it is served up. This means that if the url returns UTF-8, and you display it as iso-8859-1, then things will look wrong. Most likely, this is the case (But it could be the other way around). Either convert to ISO-8859-1, or change your app to use UTF-8. The former is possibly the simplest change – Pipe the content through utf8_decode, which transforms from UTF-8 to ISO-8859-1.

    E.g.:

    function getData ($url) {
        $data = file_get_contents($url);
        $data = utf8_decode($data);
        return $data;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm dynamically loading different content from db, using ajax. So, when I'm loading plain
On my website, I am loading the content dynamically from database like this e.g
I have a Facebook feed located via this URL: https://www.facebook.com/feeds/page.php?id=131872766880896&format=json . It's in JSON
I'm having issues with loading the user's information into Flash from a PHP script.
I'm trying to implement this method of making a nice form upload: www.kavoir.com/2009/02/styling-file-upload-select-input-control-input-typefile.html/ which
Using either .ajax or .load, I'm loading content from an .html page into or
I am loading content from a series of links like this : <div id=tagList
I'm creating a div with jquery, loading content from webserver with load, and then
Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: _CFXMLNodeGetInfoPtr Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security Expected in:
I am loading contents into a same domain iframe. Does the html file that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.