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 86609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:16:23+00:00 2026-05-10T22:16:23+00:00

I have a small program to order and sort email messages, outputting to a

  • 0

I have a small program to order and sort email messages, outputting to a textfile using $msg->decoded->string. The perl program outputs to stdout, and I redirect it to a txt file. However, gedit is unable to open this text file because of a character set problem, and I would like to know how to restore or set a character set with perl.

The program is now thus:

#!/usr/bin/perl use warnings; use strict; use Mail::Box::Manager;  open (MYFILE, '>>data.txt');  my $file = shift || $ENV{MAIL}; my $mgr = Mail::Box::Manager->new(     access          => 'r', );  my $folder = $mgr->open( folder => $file ) or die '$file: Unable to open: $!\n';  for my $msg ( sort { $a->timestamp <=> $b->timestamp } $folder->messages) {     my $to          = join( ', ', map { $_->format } $msg->to );     my $from        = join( ', ', map { $_->format } $msg->from );     my $date        = localtime( $msg->timestamp );     my $subject     = $msg->subject;     my $body        = $msg->decoded->string;      # Strip all quoted text     $body =~ s/^>.*$//msg;      print MYFILE <<''; From: $from To: $to Date: $date $body  } 

However I get the same problem that I am unable to open the file with gedit, even though it works with vi or such. If there are non unicode characters in the file, would this break it?

  • 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. 2026-05-10T22:16:23+00:00Added an answer on May 10, 2026 at 10:16 pm

    Different messages probably are in different encodings. Probably gedit detects it as UTF-8, but later finds out that parts of the file aren’t UTF-8. Mixed files like this are major PITA.

    The best (perhaps only) solution is to check for the content type ($message->contentType) and convert everything to UTF-8.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small program <350ish lines of code on 5 forms>. It works
i have a small program where an element is draged and dropped, when the
I have a small program to do in Java. I have a 2D array
I have a small program I want to execute to test something #include <map>
I have a small program that's supposed to sample some value from a device
I have a small program that reads in a file and processes the data
I have a small program that I'm trying to create to get ip addresses
I have made a small program in C# that I want to run in
I have written a small program in C to get IP from remote user
I have written a small program to create thread and change their default stack

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.