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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 256k
  • Answers 257k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Another option is to use a distributed cache such as… May 13, 2026 at 10:39 am
  • Editorial Team
    Editorial Team added an answer From the Edit Control documentation: The length of text that… May 13, 2026 at 10:39 am
  • Editorial Team
    Editorial Team added an answer This will be in C#, but it should get you… May 13, 2026 at 10:39 am

Related Questions

I'm looking to create a very small cataloguing app for personal use (although I'd
I have a SAS program that loops through certain sets of data and generates
I've got some library code that works on a range of .NET runtimes (regular,
I'm writing a small program to convert a standard definition 4:3 video to a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.